-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #158 from wantero/master
Esqueci minha senha e data de escolha
- Loading branch information
Showing
14 changed files
with
220 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/app/components/forgot-password/forgot-password.component.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
form i.fa { | ||
position: absolute; | ||
top: 8px; | ||
left: 15px; | ||
color: #2098D1; | ||
font-size: 22px; | ||
z-index: 99; | ||
} | ||
|
||
.form-control { | ||
position: relative; | ||
padding-left: 45px !important; | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
src/app/components/forgot-password/forgot-password.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<form [formGroup]="formGroup" class="container form-horizontal" (ngSubmit)="changePassword()"> | ||
<input formControlName="hashCodePassword" type="hidden" class="form-control"> | ||
<h1 class="text-center display-4">Redefinir Senha</h1> | ||
<div class="form-row"> | ||
<div class="col"> | ||
|
||
<div class="form-group col-md-6 offset-md-3 mb-2"> | ||
<label class="col-form-label" for="newPassword">Nova Senha</label> | ||
<div class="input-group"> | ||
<input formControlName="newPassword" type="password" class="form-control"> | ||
<div class="input-group-addon append"> | ||
<i class="fa fa-unlock-alt"></i> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="formGroup.controls['newPassword'].touched && !formGroup.controls['newPassword'].valid"> | ||
<small class="form-text text-danger" *ngIf="formGroup.controls['newPassword'].hasError('required')"> | ||
Nova senha obrigatória. | ||
</small> | ||
<small class="form-text text-danger" *ngIf="formGroup.controls['newPassword'].hasError('pattern')"> | ||
A senha não atende os requisitos. Mínimo oito caracteres, um caractere especial | ||
(@$!%*?&#.,-_:;), um caractere numérico e uma letra | ||
em maiúsculo. | ||
</small> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group col-md-6 offset-md-3 mb-2"> | ||
<label class="col-form-label" for="confirmPassword">Confirmar Nova Senha</label> | ||
<div class="input-group"> | ||
<input formControlName="confirmPassword" type="password" class="form-control"> | ||
<div class="input-group-addon append"> | ||
<i class="fa fa-unlock-alt"></i> | ||
</div> | ||
</div> | ||
|
||
<div *ngIf="formGroup.controls['confirmPassword'].touched && !formGroup.controls['confirmPassword'].valid"> | ||
<small class="form-text text-danger" *ngIf="formGroup.controls['confirmPassword'].hasError('required')"> | ||
Confirmação de senha obrigatória. | ||
</small> | ||
<small class="form-text text-danger" *ngIf="formGroup.controls['confirmPassword'].hasError('MatchPassword') "> | ||
A confirmação de senha não confere com a nova senha informada. | ||
</small> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group col-md-6 offset-md-3"> | ||
<div class="text-center"> | ||
<input type="submit" class="btn btn-primary" value="Redefinir" style="padding-left: 50px; padding-right: 50px" | ||
[disabled]="!formGroup.valid"> | ||
<a [routerLink]="['/login']" class="btn btn-link">Cancelar</a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</form> |
49 changes: 49 additions & 0 deletions
49
src/app/components/forgot-password/forgot-password.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* tslint:disable:no-unused-variable */ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { DebugElement } from '@angular/core'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { RouterTestingModule } from '@angular/router/testing'; | ||
import { HttpClient, HttpHandler } from '@angular/common/http'; | ||
|
||
import { ForgotPasswordComponent } from './forgot-password.component'; | ||
|
||
import { AppConfigModule } from '../../app-config.module'; | ||
import { UserService } from '../../core/services/user/user.service'; | ||
import { AlertService } from '../../core/services/alert/alert.service'; | ||
|
||
describe('ForgotPasswordComponent', () => { | ||
let component: ForgotPasswordComponent; | ||
let fixture: ComponentFixture<ForgotPasswordComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
ForgotPasswordComponent | ||
], | ||
imports: [ | ||
FormsModule, | ||
ReactiveFormsModule, | ||
RouterTestingModule, | ||
AppConfigModule | ||
], | ||
providers: [ | ||
UserService, | ||
HttpClient, | ||
HttpHandler, | ||
AlertService | ||
] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(ForgotPasswordComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
69 changes: 69 additions & 0 deletions
69
src/app/components/forgot-password/forgot-password.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators, FormArray, FormControl } from '@angular/forms'; | ||
import { Router, ActivatedRoute } from '@angular/router'; | ||
|
||
import { UserService } from '../../core/services/user/user.service'; | ||
import { AlertService } from '../../core/services/alert/alert.service'; | ||
import { PasswordValidation } from '../../core/utils/passwordValidation'; | ||
import * as AppConst from '../../core/utils/app.const'; | ||
|
||
@Component({ | ||
selector: 'app-forgot-password', | ||
templateUrl: './forgot-password.component.html', | ||
styleUrls: ['./forgot-password.component.css'] | ||
}) | ||
export class ForgotPasswordComponent implements OnInit { | ||
|
||
formGroup: FormGroup; | ||
|
||
constructor( | ||
private _activatedRoute: ActivatedRoute, | ||
private _router: Router, | ||
private _formBuilder: FormBuilder, | ||
private _scUser: UserService, | ||
private _scAlert: AlertService | ||
) { | ||
this.formGroup = _formBuilder.group({ | ||
hashCodePassword: ['', Validators.required], | ||
newPassword: ['', [Validators.required, Validators.pattern(AppConst.passwordPattern)]], | ||
confirmPassword: ['', [Validators.required]] | ||
}, { | ||
validator: PasswordValidation.MatchPassword | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
let hashCodePassword = ''; | ||
this._activatedRoute.params.subscribe((param) => { | ||
hashCodePassword = param.hashCodePassword; | ||
|
||
const changeUserPasswordByHashCodeVM = { | ||
hashCodePassword: hashCodePassword, | ||
newPassword: '', | ||
confirmPassword: '' | ||
}; | ||
|
||
this.formGroup.setValue(changeUserPasswordByHashCodeVM); | ||
}); | ||
|
||
} | ||
|
||
changePassword() { | ||
if (this.formGroup.valid) { | ||
this._scUser.changeUserPasswordByHashCode(this.formGroup.value).subscribe( | ||
data => { | ||
if (data.success || data.authenticated) { | ||
this._scAlert.success('Senha atualizada com sucesso', true); | ||
this._router.navigate(['/login']); | ||
} else { | ||
this._scAlert.error(data.messages[0]); | ||
} | ||
}, | ||
error => { | ||
this._scAlert.error(error); | ||
} | ||
); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class ChangeUserPasswordByHashCodeVM { | ||
hashCodePassword: string; | ||
newPassword: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters