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
import { Component, OnInit } from '@angular/core'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { AuthService } from 'src/app/shared/services/auth.service'; | |
import { ProgressBarService } from 'src/app/shared/services/progress-bar.service'; | |
import { AlertService } from 'ngx-alerts'; | |
@Component({ | |
selector: 'app-change-password', | |
templateUrl: './change-password.component.html', | |
styleUrls: ['./change-password.component.scss'] |
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
changePassword() { | |
this.progressBar.startLoading(); | |
this.authService.changePassword(this.model).subscribe(() => { | |
this.progressBar.setSuccess(); | |
console.log("success"); | |
this.progressBar.completeLoading(); | |
}, error => { | |
this.progressBar.setError(); | |
console.log(error); | |
this.progressBar.completeLoading(); |
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
import { HttpClient, HttpHeaders } from '@angular/common/http'; | |
// Inside class | |
employersUrl = "http://localhost:5000/api/employers/"; | |
confirmEmailUrl = "test.com"; | |
// Method | |
register(model: any) { |
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
import { AuthService } from 'src/app/shared/services/auth.service'; | |
constructor(private authService: AuthService) { } | |
onSubmit(f: NgForm) { | |
const loginObserver = { | |
next: x => console.log('User logged in'), |
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
return Ok(new | |
{ | |
result = result, | |
token = JwtTokenGeneratorMachine(user).Result | |
}); |
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
onSubmit(f: NgForm) { | |
console.log(f.value); // { first: '', last: '' } | |
console.log(f.valid); // false | |
} |
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
<div class="row"> | |
<div class="col-md-6 offset-md-3 mt-4"> | |
<h3>Login</h3> | |
<form> | |
<div class="form-group"> | |
<label for="loginUsername">Username</label> | |
<input type="text" | |
class="form-control" | |
id="loginUsername" | |
placeholder="Enter username"> |
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
<ul class="navbar-nav"> | |
<li class="nav-item"> | |
<a class="nav-link" | |
href="#">Register</a> | |
[routerLink]="['register']" | |
routerLinkActive="active">Register</a> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link" | |
href="#">Login</a> |
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
// Post api/auth/resetpassword | |
[HttpPost("resetpassword")] | |
public async Task<IActionResult> ResetPassword(ResetPasswordViewModel model) | |
{ | |
var user = await _userManager.FindByEmailAsync(model.Email); | |
if (user != null || user.EmailConfirmed) | |
{ | |
//Send Email | |
var token = await _userManager.GeneratePasswordResetTokenAsync(user); | |
var changePasswordUrl = Request.Headers["changePasswordUrl"];//http://localhost:4200/change-password |
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
// Post api/auth/confirmemail | |
[HttpPost("confirmemail")] | |
public async Task<IActionResult> ConfirmEmail(ConfirmEmailViewModel model) | |
{ | |
var employer = await _userManager.FindByIdAsync(model.UserId); | |
var confirm = await _userManager.ConfirmEmailAsync(employer, Uri.UnescapeDataString(model.Token)); | |
if (confirm.Succeeded) | |
{ | |
return Ok(); |