feat : maj du mot de passe
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { AuthRepository, AuthResponse } from '@app/domain/authentification/auth.repository';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { User } from '@app/domain/users/user.model';
|
||||
import { LoginDto } from '@app/domain/authentification/dto/login-dto';
|
||||
import { RegisterDto } from '@app/domain/authentification/dto/register-dto';
|
||||
import { fakeUsers } from '@app/testing/user.mock';
|
||||
|
||||
export class FakeAuthRepository implements AuthRepository {
|
||||
confirmPasswordReset(
|
||||
resetToken: string,
|
||||
newPassword: string,
|
||||
confirmPassword: string
|
||||
): Observable<boolean> {
|
||||
return of(true);
|
||||
}
|
||||
|
||||
get(): User | undefined {
|
||||
return fakeUsers[0];
|
||||
}
|
||||
|
||||
isAuthenticated(): boolean {
|
||||
return fakeUsers[0] !== undefined;
|
||||
}
|
||||
|
||||
isEmailVerified(): boolean {
|
||||
return fakeUsers[0].verified;
|
||||
}
|
||||
|
||||
login(loginDto: LoginDto): Observable<AuthResponse> {
|
||||
const user = fakeUsers.find((u) => u.email === loginDto.email);
|
||||
return of({ isValid: true, record: user, token: 'fakeToken' } as AuthResponse);
|
||||
}
|
||||
|
||||
logout(): void {
|
||||
fakeUsers.pop();
|
||||
}
|
||||
|
||||
register(registerDto: RegisterDto): Observable<User> {
|
||||
const user = {
|
||||
...fakeUsers[0],
|
||||
id: 'fakeId',
|
||||
email: registerDto.email,
|
||||
};
|
||||
fakeUsers.push(user);
|
||||
return of(user);
|
||||
}
|
||||
|
||||
sendRequestPasswordReset(email: string): Observable<boolean> {
|
||||
return of(fakeUsers[0].email === email);
|
||||
}
|
||||
|
||||
sendVerificationEmail(email: string): Observable<boolean> {
|
||||
return of(fakeUsers[0].email === email);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user