mirror of
https://github.com/getnamingo/registry.git
synced 2025-05-30 01:10:09 +02:00
Fixed CP password reset
This commit is contained in:
parent
fbc62d587f
commit
af5bbacfe7
6 changed files with 77 additions and 36 deletions
|
@ -183,14 +183,16 @@ class Auth
|
|||
* @param $email
|
||||
* @throws \Pinga\Auth\AuthError
|
||||
*/
|
||||
public static function forgotPassword($email){
|
||||
public static function forgotPassword($email,$username){
|
||||
$auth = self::$auth;
|
||||
try {
|
||||
$auth->forgotPassword($email, function ($selector, $token) use ($email) {
|
||||
$auth->forgotPassword($email, function ($selector, $token) use ($email,$username) {
|
||||
$link = url('reset.password',[],['selector'=>urlencode($selector),'token'=>urlencode($token)]);
|
||||
$message = file_get_contents(__DIR__.'/../../resources/views/auth/mail/reset-password.html');
|
||||
$message = str_replace(['{link}','{app_name}'],[$link,envi('APP_NAME')],$message);
|
||||
$subject = 'Reset Password';
|
||||
$placeholders = ['{user_first_name}', '{link}', '{app_name}'];
|
||||
$replacements = [ucfirst($username), $link, envi('APP_NAME')];
|
||||
$message = str_replace($placeholders, $replacements, $message);
|
||||
$subject = '[' . envi('APP_NAME') . '] Action Required: Reset Your Password';
|
||||
$from = ['email'=>envi('MAIL_FROM_ADDRESS'), 'name'=>envi('MAIL_FROM_NAME')];
|
||||
$to = ['email'=>$email, 'name'=>''];
|
||||
// send message
|
||||
|
|
|
@ -32,8 +32,11 @@ class PasswordController extends Controller
|
|||
* @throws \Pinga\Auth\AuthError
|
||||
*/
|
||||
public function forgotPassword(Request $request, Response $response){
|
||||
global $container;
|
||||
$db = $container->get('db');
|
||||
$data = $request->getParsedBody();
|
||||
Auth::forgotPassword($data['email']);
|
||||
$username = $db->selectValue('SELECT username FROM users WHERE email = ?', [$data['email']]);
|
||||
Auth::forgotPassword($data['email'],$username);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
"php-di/php-di": "^7.0.6",
|
||||
"nyholm/psr7": "^1.8.1",
|
||||
"nyholm/psr7-server": "^1.1.0",
|
||||
"pinga/auth": "^0.3.3",
|
||||
"pinga/auth": "^0.3.4",
|
||||
"filp/whoops": "^2.15.3",
|
||||
"imefisto/psr-swoole-native": "^1.1.2",
|
||||
"chubbyphp/chubbyphp-static-file": "^1.2",
|
||||
|
|
|
@ -173,9 +173,9 @@
|
|||
<table align="center" border="0" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;border-spacing:0px;">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:64px;">
|
||||
<td style="width:180px;">
|
||||
|
||||
<img height="auto" src="https://i.imgur.com/KO1vcE9.png" style="border:0;display:block;outline:none;text-decoration:none;width:100%;" width="64" />
|
||||
<img height="auto" src="https://namingo.org/logo.png" style="border:0;display:block;outline:none;text-decoration:none;width:100%;" width="180" />
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
@ -189,7 +189,16 @@
|
|||
<td align="center" style="font-size:0px;padding:10px 25px;padding-bottom:40px;word-break:break-word;">
|
||||
|
||||
<div style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:18px;line-height:1;text-align:center;color:#555;">
|
||||
Password reset request
|
||||
<p>Dear {user_first_name},</p>
|
||||
<p>We received a request to reset the password for your account. If you did not initiate this request, please rest assured that your account remains secure and you can safely disregard this email.</p>
|
||||
</div>
|
||||
|
||||
<div style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:18px;line-height:1;text-align:center;color:#555;">
|
||||
<p><strong>To Reset Your Password:</strong></p>
|
||||
<ol>
|
||||
<li>Click the button below within the next 24 hours. If the link expires, you can initiate a new password reset request.</li>
|
||||
<li>Follow the instructions to create a new password.</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
@ -216,7 +225,23 @@
|
|||
<td align="center" style="font-size:0px;padding:10px 25px;padding-bottom:40px;word-break:break-word;">
|
||||
|
||||
<div style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:16px;line-height:20px;text-align:center;color:#7F8FA4;">
|
||||
If you did not make this request, just ignore this email. Otherwise please click the button above to reset your password.
|
||||
<p>For your security, please ensure your new password:</p>
|
||||
<ul>
|
||||
<li>Is at least 8 characters long.</li>
|
||||
<li>Contains a mix of letters, numbers, and symbols.</li>
|
||||
<li>Is not used for any other accounts.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:16px;line-height:20px;text-align:center;color:#7F8FA4;">
|
||||
<p><strong>Didn't Request a Password Reset?</strong></p>
|
||||
<p>If you did not request a password reset, no further action is required. However, it's a good practice to regularly update your password and review your account security settings.</p>
|
||||
<p>Thank you for taking the time to keep your account secure.</p>
|
||||
</div>
|
||||
|
||||
<div style="font-family:'Helvetica Neue',Arial,sans-serif;font-size:16px;line-height:20px;text-align:center;color:#7F8FA4;">
|
||||
<p>Best regards,<br />
|
||||
{app_name} Support Team</p>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
</div>
|
||||
<div class="form-footer">
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<!-- Download SVG icon from http://tabler-icons.io/i/mail -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><rect x="3" y="5" width="18" height="14" rx="2" /><polyline points="3 7 12 13 21 7" /></svg>
|
||||
Send me new password
|
||||
</button>
|
||||
|
|
|
@ -1,29 +1,41 @@
|
|||
{% extends "layouts/auth.twig" %}
|
||||
|
||||
{% block title %}Update Password{% endblock %}
|
||||
{% block title %}Reset Password{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form action="{{route('update.password')}}" name="register" method="post">
|
||||
{{ csrf.field | raw }}
|
||||
<input type="hidden" name="selector" value="{{selector}}">
|
||||
<input type="hidden" name="token" value="{{token}}">
|
||||
<div class="row d-flex align-items-center justify-content-center">
|
||||
<div class="col-md-6">
|
||||
<div class="card px-5 py-5">
|
||||
<h5 class="mt-3">Reset Password</h5>
|
||||
<div class="form-input{{ errors.password ? ' has-error' : '' }}">
|
||||
<i class="fa fa-lock"></i> <input type="password" name="password" class="form-control" placeholder="Enter password">
|
||||
{% if errors.password %}
|
||||
<span class="hel-block">{{ errors.password | first }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-input">
|
||||
<i class="fa fa-lock"></i> <input type="password" name="password2" class="form-control" placeholder="Re-enter password">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary mt-4 signup">Reset Password</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
|
||||
<div class="page page-center">
|
||||
<div class="container container-tight py-4">
|
||||
<div class="text-center mb-4">
|
||||
<a href="." class="navbar-brand navbar-brand-autodark"><img src="./static/logo-bw.svg" height="36" alt=""></a>
|
||||
{% include 'partials/flash.twig' %}
|
||||
</div>
|
||||
<form class="card card-md" action="{{route('update.password')}}" name="register" method="post" autocomplete="off">
|
||||
{{ csrf.field | raw }}
|
||||
<input type="hidden" name="selector" value="{{selector}}">
|
||||
<input type="hidden" name="token" value="{{token}}">
|
||||
<div class="card-body">
|
||||
<h2 class="card-title text-center mb-4">Reset Password</h2>
|
||||
<p class="text-muted mb-4">You're just a step away from resetting your password. Please enter your new password below. Make sure it's strong and unique to keep your account secure.</p>
|
||||
<div class="mb-3 form-input{{ errors.password ? ' has-error' : '' }}">
|
||||
<i class="fa fa-lock"></i> <input type="password" name="password" class="form-control" placeholder="Enter password">
|
||||
{% if errors.password %}
|
||||
<span class="hel-block">{{ errors.password | first }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="form-input">
|
||||
<i class="fa fa-lock"></i> <input type="password" name="password2" class="form-control" placeholder="Re-enter password">
|
||||
</div>
|
||||
<div class="form-footer">
|
||||
<button type="submit" class="btn btn-primary w-100">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M20 11a8.1 8.1 0 0 0 -15.5 -2m-.5 -4v4h4" /><path d="M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4" /></svg>
|
||||
Reset Password
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="text-center text-muted mt-3">
|
||||
Forget it, <a href="{{route('login')}}">send me back</a> to the sign in screen.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue