[WIP] Fixed forgot password #70
This commit is contained in:
parent
47a73a4298
commit
d0ded956cb
@ -16,10 +16,10 @@
|
||||
"LicenseName": "MIT",
|
||||
"LicenseDescription": "MIT, see LICENSE for more details.",
|
||||
"Dependencies": [
|
||||
"cpl-core==2022.10.0.post6",
|
||||
"cpl-core==2022.10.0.post7",
|
||||
"cpl-translation==2022.10.0.post1",
|
||||
"cpl-query==2022.10.0.post2",
|
||||
"cpl-discord==2022.10.0.post5",
|
||||
"cpl-discord==2022.10.0.post6",
|
||||
"Flask==2.2.2",
|
||||
"Flask-Classful==0.14.2",
|
||||
"Flask-Cors==3.0.10",
|
||||
|
@ -6,6 +6,7 @@ from typing import Optional
|
||||
|
||||
import jwt
|
||||
from cpl_core.database.context import DatabaseContextABC
|
||||
from cpl_core.environment import ApplicationEnvironmentABC
|
||||
from cpl_core.mailing import EMailClientABC, EMail
|
||||
from cpl_query.extension import List
|
||||
from cpl_translation import TranslatePipe
|
||||
@ -35,6 +36,7 @@ class AuthService(AuthServiceABC):
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
env: ApplicationEnvironmentABC,
|
||||
logger: ApiLogger,
|
||||
auth_users: AuthUserRepositoryABC,
|
||||
db: DatabaseContextABC,
|
||||
@ -46,6 +48,7 @@ class AuthService(AuthServiceABC):
|
||||
):
|
||||
AuthServiceABC.__init__(self)
|
||||
|
||||
self._environment = env
|
||||
self._logger = logger
|
||||
self._auth_users = auth_users
|
||||
self._db = db
|
||||
@ -54,14 +57,6 @@ class AuthService(AuthServiceABC):
|
||||
self._auth_settings = auth_settings
|
||||
self._frontend_settings = frontend_settings
|
||||
|
||||
@staticmethod
|
||||
def _get_mail_to_send() -> EMail:
|
||||
mail = EMail()
|
||||
mail.add_header('Mime-Version: 1.0')
|
||||
mail.add_header('Content-Type: text/plain charset=utf-8')
|
||||
mail.add_header('Content-Transfer-Encoding: quoted-printable')
|
||||
return mail
|
||||
|
||||
@staticmethod
|
||||
def _hash_sha256(password: str, salt: str) -> str:
|
||||
return hashlib.sha256(f'{password}{salt}'.encode('utf-8')).hexdigest()
|
||||
@ -141,10 +136,14 @@ class AuthService(AuthServiceABC):
|
||||
if not url.endswith('/'):
|
||||
url = f'{url}/'
|
||||
|
||||
mail = self._get_mail_to_send()
|
||||
mail = EMail()
|
||||
mail.add_header('Mime-Version: 1.0')
|
||||
mail.add_header('Content-Type: text/plain charset=utf-8')
|
||||
mail.add_header('Content-Transfer-Encoding: quoted-printable')
|
||||
mail.add_receiver(user.email)
|
||||
mail.subject = self._t.transform('api.auth.confirmation.subject').format(user.first_name, user.last_name)
|
||||
mail.body = self._t.transform('api.auth.confirmation.message').format(url, user.confirmation_id)
|
||||
mail.body += f'\n\nDies ist eine automatische E-Mail.\nGesendet von {self._environment.application_name}-{self._environment.environment_name}@{self._environment.host_name}'
|
||||
self._mailer.send_mail(mail)
|
||||
|
||||
def _send_forgot_password_id_to_user(self, user: AuthUser):
|
||||
@ -152,10 +151,14 @@ class AuthService(AuthServiceABC):
|
||||
if not url.endswith('/'):
|
||||
url = f'{url}/'
|
||||
|
||||
mail = self._get_mail_to_send()
|
||||
mail = EMail()
|
||||
mail.add_header('Mime-Version: 1.0')
|
||||
mail.add_header('Content-Type: text/plain charset=utf-8')
|
||||
mail.add_header('Content-Transfer-Encoding: quoted-printable')
|
||||
mail.add_receiver(user.email)
|
||||
mail.subject = self._t.transform('api.auth.forgot_password.subject').format(user.first_name, user.last_name)
|
||||
mail.body = self._t.transform('api.auth.forgot_password.message').format(url, user.forgot_password_id)
|
||||
mail.subject = str(self._t.transform('api.auth.forgot_password.subject').format(user.first_name, user.last_name))
|
||||
mail.body = str(self._t.transform('api.auth.forgot_password.message').format(url, user.forgot_password_id))
|
||||
mail.body += f'\n\nDies ist eine automatische E-Mail.\nGesendet von {self._environment.application_name}-{self._environment.environment_name}@{self._environment.host_name}'
|
||||
self._mailer.send_mail(mail)
|
||||
|
||||
async def get_all_auth_users_async(self) -> List[AuthUserDTO]:
|
||||
|
@ -37,6 +37,7 @@ export class ForgetPasswordComponent implements OnInit {
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
console.log('test');
|
||||
this.spinnerService.showSpinner();
|
||||
this.authService.isUserLoggedInAsync().then(result => {
|
||||
if (result) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="login-form-wrapper">
|
||||
<div class="login-form">
|
||||
<form [formGroup]="loginForm">
|
||||
<h1>sh-edraft.de</h1>
|
||||
<h1>{{'auth.header' | translate}}</h1>
|
||||
<div class="input-field">
|
||||
<input type="email" pInputText formControlName="email" placeholder="{{'auth.login.e_mail' | translate}}" [ngClass]="{ 'invalid-feedback-input': submitted && (
|
||||
(loginForm.controls.email.errors && loginForm.controls.email.errors['required'] || authUserAtrErrors.email.required) ||
|
||||
|
@ -102,8 +102,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
forgotPassword(email: string): Observable<unknown> {
|
||||
const emailJson = JSON.stringify(email);
|
||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/forgot-password`, emailJson, {
|
||||
return this.http.post(`${this.appsettings.getApiURL()}/api/auth/forgot-password/${email}`, {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
@ -111,8 +110,7 @@ export class AuthService {
|
||||
}
|
||||
|
||||
getEMailFromforgotPasswordId(id: string): Observable<EMailStringDTO> {
|
||||
const idJson = JSON.stringify(id);
|
||||
return this.http.post<EMailStringDTO>(`${this.appsettings.getApiURL()}/api/auth/confirm-forgot-password`, idJson, {
|
||||
return this.http.post<EMailStringDTO>(`${this.appsettings.getApiURL()}/api/auth/confirm-forgot-password/${id}`, {
|
||||
headers: new HttpHeaders({
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
|
@ -166,12 +166,12 @@ header {
|
||||
|
||||
.input-field-info-text {
|
||||
margin: 15px 0px;
|
||||
width: 240px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-form-submit {
|
||||
.login-form-submit-btn {
|
||||
width: 240px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@ -395,12 +395,12 @@ footer {
|
||||
|
||||
.input-field-info-text {
|
||||
margin: 15px 0px;
|
||||
width: 240px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.login-form-submit {
|
||||
.login-form-submit-btn {
|
||||
width: 240px;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@ -440,7 +440,7 @@ footer {
|
||||
input,
|
||||
.p-password {
|
||||
height: 40px;
|
||||
width: 240px;
|
||||
width: 100%;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user