Bugfix/list clickup issue #5
@@ -217,7 +217,9 @@ class AuthController extends Controller
|
||||
$user['is_verified'] = 0;
|
||||
$user->save();
|
||||
|
||||
Mail::to($request->email)->send(new ResetPassword($user->name, $token));
|
||||
$resetUrl = rtrim(config('app.app_pembida'), '/') . '/reset-password/' . $token;
|
||||
|
||||
Mail::to($request->email)->send(new ResetPassword($user->name, $resetUrl));
|
||||
|
||||
if (Mail::failures() != 0) {
|
||||
return response()->json([
|
||||
@@ -232,6 +234,59 @@ class AuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function validateResetToken($token)
|
||||
{
|
||||
$user = User::where('token', $token)->where('is_verified', 0)->first();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pautan tetapan semula kata laluan tidak sah atau telah tamat tempoh.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
}
|
||||
|
||||
public function updatePassword(Request $request)
|
||||
{
|
||||
$validator = Validator::make($request->all(), [
|
||||
'token' => 'required|string',
|
||||
'password' => 'required|string|min:6',
|
||||
'confirm_password' => 'required|same:password',
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => $validator->errors()->first(),
|
||||
'errors' => $validator->errors(),
|
||||
], 422);
|
||||
}
|
||||
|
||||
$user = User::where('token', $request->token)->where('is_verified', 0)->first();
|
||||
|
||||
if (!$user) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Pautan tetapan semula kata laluan tidak sah atau telah tamat tempoh.',
|
||||
], 422);
|
||||
}
|
||||
|
||||
$user->password = Hash::make($request->password);
|
||||
$user->token = null;
|
||||
$user->is_verified = 0;
|
||||
$user->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'message' => 'Katalaluan anda telah berjaya dikemaskini.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
$user = Auth::user();
|
||||
|
||||
@@ -734,7 +734,10 @@ class HomeController extends Controller
|
||||
return view('homecawangan', compact('all_lelong', 'arrayinfomutu'));
|
||||
} else {
|
||||
Auth::logout();
|
||||
return redirect()->route('login');
|
||||
return redirect()->route('login')->with(
|
||||
'failed',
|
||||
'Akaun ini tiada peranan (role) yang sah. Sila hubungi admin untuk tetapkan role.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,7 +113,9 @@ class UserController extends Controller
|
||||
$user['is_verified'] = 0;
|
||||
$user->save();
|
||||
|
||||
Mail::to($request->email)->send(new ResetPassword($user->name, $token));
|
||||
$resetUrl = url('/forgot-password/' . $token);
|
||||
|
||||
Mail::to($request->email)->send(new ResetPassword($user->name, $resetUrl));
|
||||
|
||||
if(Mail::failures() != 0) {
|
||||
return back()->with('success', 'Berjaya DiHantar! Pautan Lupa Katalaluan Telah Dihantarkan Kepada Alamat Emel Anda.');
|
||||
|
||||
@@ -11,33 +11,22 @@ class ResetPassword extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public $name;
|
||||
public $token;
|
||||
public $resetUrl;
|
||||
|
||||
public function __construct($name, $token)
|
||||
public function __construct($name, $resetUrl)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->token = $token;
|
||||
$this->resetUrl = $resetUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*git stsa
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
// return $this->view('view.name');
|
||||
$user['name'] = $this->name;
|
||||
$user['token'] = $this->token;
|
||||
$user['reset_url'] = $this->resetUrl;
|
||||
|
||||
return $this->from("masterlelongpkb@gmail.com", "Admin ArrahnBid")
|
||||
->subject('ArrahnBid -Tukar Katalaluan')
|
||||
->view('template.reset-password', ['user' => $user]);
|
||||
return $this->from(config('mail.from.address'), config('mail.from.name'))
|
||||
->subject('ArrahnBid - Tukar Katalaluan')
|
||||
->view('template.reset-password', ['user' => $user]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
@if (session('success'))
|
||||
<div class="notice notice-success" role="status">{{ session('success') }}</div>
|
||||
@endif
|
||||
@if (session('failed'))
|
||||
<div class="notice notice-error" role="alert">{{ session('failed') }}</div>
|
||||
@if (session('failed') || session('error'))
|
||||
<div class="notice notice-error" role="alert">{{ session('failed') ?? session('error') }}</div>
|
||||
@endif
|
||||
<form method="POST" action="{{ route('login') }}">
|
||||
@csrf
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<p style="margin:100px 0 12px 0;font-size:14px;font-family:Arial,sans-serif;">
|
||||
<p style="margin:40px 0 12px 0;font-size:14px;line-height:22px;font-family:Arial,sans-serif;color:#153643;">
|
||||
Terima Kasih,
|
||||
</p>
|
||||
<p style="margin:0 0 12px 0;font-size:14px;font-family:Arial,sans-serif;">
|
||||
<p style="margin:0 0 8px 0;font-size:14px;line-height:22px;font-family:Arial,sans-serif;color:#153643;font-weight:700;">
|
||||
ArrahnBid
|
||||
</p>
|
||||
</td>
|
||||
@@ -9,6 +9,32 @@
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:20px 28px;border-top:1px solid #e5e7eb;background:#fafbfc;">
|
||||
<table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;">
|
||||
<tr>
|
||||
<td align="center" style="padding:0 0 10px 0;">
|
||||
<img
|
||||
src="{{ asset('img/icon_pkb.png') }}"
|
||||
width="72"
|
||||
alt="ArrahnBid"
|
||||
style="display:inline-block;border:0;outline:none;text-decoration:none;width:72px;height:auto;vertical-align:middle;"
|
||||
>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" style="padding:0 0 6px 0;font-family:Arial,sans-serif;font-size:13px;font-weight:700;color:#021d68;">
|
||||
ArrahnBid
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center" style="padding:0;font-family:Arial,sans-serif;font-size:12px;line-height:18px;color:#6b7280;">
|
||||
Emel ini dijana secara automatik. Sila jangan balas emel ini.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -32,21 +32,37 @@
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;">
|
||||
<body style="margin:0;padding:0;background:#f4f6f8;">
|
||||
<table role="presentation"
|
||||
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;">
|
||||
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#f4f6f8;">
|
||||
<tr>
|
||||
<td align="center" style="padding:0;">
|
||||
<td align="center" style="padding:24px 12px;">
|
||||
<table role="presentation"
|
||||
style="width:600px;border-collapse:collapse;border:1px solid #cccccc;border-spacing:0;text-align:left;">
|
||||
<tr style="border-collapse:collapse;border:1px solid #cccccc;border-spacing:0;">
|
||||
<td align="left" style="padding:10px 25px;background:#fff; display: flex; align-items: center;">
|
||||
<span style="font-weight: bold; padding-top: 10px;"> ArrahnBid</span>
|
||||
style="width:600px;max-width:100%;border-collapse:collapse;border:1px solid #e5e7eb;border-spacing:0;text-align:left;background:#ffffff;">
|
||||
<tr>
|
||||
<td style="padding:20px 28px;border-bottom:1px solid #e5e7eb;background:#ffffff;">
|
||||
<table role="presentation" style="width:100%;border-collapse:collapse;border:0;border-spacing:0;">
|
||||
<tr>
|
||||
<td style="vertical-align:middle;">
|
||||
<img
|
||||
src="{{ asset('img/icon_pkb.png') }}"
|
||||
width="120"
|
||||
alt="ArrahnBid"
|
||||
style="display:block;border:0;outline:none;text-decoration:none;width:120px;height:auto;"
|
||||
>
|
||||
</td>
|
||||
<td style="vertical-align:middle;padding-left:14px;">
|
||||
<span style="font-family:Arial,sans-serif;font-size:18px;font-weight:700;color:#021d68;letter-spacing:-0.2px;">
|
||||
ArrahnBid
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:36px 30px 42px 30px;">
|
||||
<td style="padding:36px 30px 24px 30px;">
|
||||
<table role="presentation"
|
||||
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;">
|
||||
<tr>
|
||||
<td style="padding:0 0 36px 0;color:#153643;">
|
||||
<td style="padding:0;color:#153643;">
|
||||
|
||||
@@ -1,82 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
||||
@include('template.partials.header')
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<meta name="x-apple-disable-message-reformatting">
|
||||
<title></title>
|
||||
<style>
|
||||
table,
|
||||
td,
|
||||
div,
|
||||
h1,
|
||||
p {
|
||||
font-weight: 500;
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
.btn {margin: 10px 0px;
|
||||
border-radius: 4px;
|
||||
text-decoration: none;
|
||||
color: #fff !important;
|
||||
height: 46px;
|
||||
padding: 10px 20px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
background-image: linear-gradient(to right top, #021d68, #052579, #072d8b, #09369d, #093fb0) !important;
|
||||
}
|
||||
.btn:hover {
|
||||
text-decoration: none;
|
||||
opacity: .8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;">
|
||||
<table role="presentation"
|
||||
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;background:#ffffff;">
|
||||
<tr>
|
||||
<td align="center" style="padding:0;">
|
||||
<table role="presentation"
|
||||
style="width:600px;border-collapse:collapse;border:1px solid #cccccc;border-spacing:0;text-align:left;">
|
||||
<tr style="border-collapse:collapse;border:1px solid #cccccc;border-spacing:0;">
|
||||
<td align="left" style="padding:10px 25px;background:#fff; display: flex; align-items: center;">
|
||||
<span style="font-weight: bold; padding-top: 10px;"> ArrahnBid</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding:36px 30px 42px 30px;">
|
||||
<table role="presentation"
|
||||
style="width:100%;border-collapse:collapse;border:0;border-spacing:0;">
|
||||
<tr>
|
||||
<td style="padding:0 0 36px 0;color:#153643;">
|
||||
<p style="font-weight:bold;margin:0 0 20px 0;font-family:Arial,sans-serif;">
|
||||
Hello {{ $user ? $user['name'] : '' }},</h1>
|
||||
<p
|
||||
style="margin:0 0 12px 0;font-size:14px;line-height:24px;font-family:Arial,sans-serif;">
|
||||
Kami telah menerima permintaan untuk menetapkan semula kata laluan.
|
||||
</p>
|
||||
<p
|
||||
style="margin:10px 0 12px 0;font-size:14px;line-height:24px;font-family:Arial,sans-serif;">
|
||||
Anda boleh menetapkan semula kata laluan anda dengan mengklik butang di bawah:
|
||||
</p>
|
||||
<p style="font-weight:bold;margin:0 0 20px 0;font-family:Arial,sans-serif;">
|
||||
Hello {{ $user ? $user['name'] : '' }},
|
||||
</p>
|
||||
<p style="margin:0 0 12px 0;font-size:14px;line-height:24px;font-family:Arial,sans-serif;">
|
||||
Kami telah menerima permintaan untuk menetapkan semula kata laluan.
|
||||
</p>
|
||||
<p style="margin:10px 0 12px 0;font-size:14px;line-height:24px;font-family:Arial,sans-serif;">
|
||||
Anda boleh menetapkan semula kata laluan anda dengan mengklik butang di bawah:
|
||||
</p>
|
||||
|
||||
<p style="text-align: center;">
|
||||
<a href="{{env('APP_URL').'forgot-password/'.$user['token']}}" class="btn">Tukar Katalaluan Anda</a>
|
||||
</p>
|
||||
<p style="text-align: center;">
|
||||
<a href="{{ $user['reset_url'] }}" class="btn">Tukar Katalaluan Anda</a>
|
||||
</p>
|
||||
|
||||
<p style="margin:10px 0 12px 0;font-size:14px;line-height:24px;font-family:Arial,sans-serif;">
|
||||
Jika butang tidak berfungsi, salin dan tampal pautan ini ke pelayar anda:
|
||||
</p>
|
||||
<p style="margin:0 0 12px 0;font-size:12px;line-height:20px;font-family:Arial,sans-serif;word-break:break-all;">
|
||||
{{ $user['reset_url'] }}
|
||||
</p>
|
||||
|
||||
<p style="margin:100px 0 12px 0;font-size:14px;font-family:Arial,sans-serif;">
|
||||
Terima Kasih, </p>
|
||||
<p style="margin:0 0 12px 0;font-size:14px;font-family:Arial,sans-serif;">
|
||||
ArrahnBid</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@include('template.partials.footer')
|
||||
|
||||
@@ -26,6 +26,8 @@ Route::post('/register', [AuthController::class, 'register']);
|
||||
Route::get('/verifyEmail', [AuthController::class, 'verifyEmail']);
|
||||
Route::post('/user/login', [AuthController::class, 'loginUser']);
|
||||
Route::post('/forgotPassword', [AuthController::class, 'forgotPassword']);
|
||||
Route::get('/resetPassword/{token}', [AuthController::class, 'validateResetToken']);
|
||||
Route::post('/resetPassword', [AuthController::class, 'updatePassword']);
|
||||
|
||||
Route::post('/password/email', [ForgotPasswordController::class, 'sendResetLinkEmail']);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user