Error and succes messages when you change password as user
This commit is contained in:
parent
8d8b5491c9
commit
f9c11e67db
|
@ -166,16 +166,16 @@ class UserController extends Controller
|
||||||
//$user->save();
|
//$user->save();
|
||||||
} else { // Else if you're not on the admin site (user site)
|
} else { // Else if you're not on the admin site (user site)
|
||||||
if ($request->input('password') != null) { // If you're editing the password
|
if ($request->input('password') != null) { // If you're editing the password
|
||||||
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back.
|
if ($request->input('password') != $request->input('confirmpassword')) { // If new password and new password confirm is not the same, go back with fail message.
|
||||||
return Response::detect("users.editpass");
|
return redirect()->route("users.accounteditpass")->with('error#notsamepass', '<p class="text-center">Der stod ikke det samme i `Nyt Password` & `Bekræft Nyt Password`!</p>');
|
||||||
} elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back.
|
} elseif (!Hash::check($request->input('oldpassword'), $user->password)) { // If the written current password and current password in DB is not the same, go back with fail message.
|
||||||
return Response::detect("users.editpass");
|
return redirect()->route("users.accounteditpass")->with('error#oldpass', '<p class="text-center">Det indtastede password i `Nuværende Password` er ikke dit nuværende password!</p>');
|
||||||
} else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.
|
} else { // If new password and current password is the same AND current written and current DB password is the same. Then update and logout.
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user->update($data);
|
$user->update($data);
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
|
|
||||||
return redirect()->route("users.login");
|
return redirect()->route("users.login")->with('success#passwordchange', '<p class="text-center">Dit password er hermed ændret!</p>');
|
||||||
}
|
}
|
||||||
} else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
|
} else { // Else if you're not editing the password but anything else (Email, Phone Number). Then update user.
|
||||||
$user->update($data);
|
$user->update($data);
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
<input type="password" name="password" id="new" required>
|
<input type="password" name="password" id="new" required>
|
||||||
<span>Bekræft Nyt Password:</span>
|
<span>Bekræft Nyt Password:</span>
|
||||||
<input type="password" name="confirmpassword" id="confirm" required>
|
<input type="password" name="confirmpassword" id="confirm" required>
|
||||||
|
{!! session()->get('error#notsamepass') !!}
|
||||||
|
{!! session()->get('error#oldpass') !!}
|
||||||
<button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>
|
<button type="submit" class="btn text-center btn-sde-blue mt-1">Rediger</button>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
<span class="toggle__text text-white">Remember password</span>
|
<span class="toggle__text text-white">Remember password</span>
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
{!! session()->get('success#passwordchange') !!}
|
||||||
<input class="btn btn-dark" type="submit" value="Sign in">
|
<input class="btn btn-dark" type="submit" value="Sign in">
|
||||||
</form>
|
</form>
|
||||||
<a class="text-white text-center" href="{{ route('users.show-forgot') }}">Forgot password?</a>
|
<a class="text-white text-center" href="{{ route('users.show-forgot') }}">Forgot password?</a>
|
||||||
|
|
Loading…
Reference in New Issue