This file contains hidden or 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
| sudo openssl pkcs12 -export -in /etc/letsencrypt/live/domain.com/fullchain.pem -inkey /etc/letsencrypt/live/domain.com/privkey.pem -out domain.com.pfx |
This file contains hidden or 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
| Verifying my Blockstack ID is secured with the address 1NPnrfmQHVDmDTKpDnNzhkPyPH6ZxSnyhj https://explorer.blockstack.org/address/1NPnrfmQHVDmDTKpDnNzhkPyPH6ZxSnyhj |
This file contains hidden or 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
| :host { | |
| height: 100%; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| .form-container { | |
| height: 300px; | |
| width: 350px; | |
| } |
This file contains hidden or 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
| const routes: Routes = [ | |
| // Home Page Route path '' | |
| { | |
| path: '', | |
| component: HomePageComponent, | |
| canActivate: [AuthGuard] | |
| }, | |
| // Login Page route path /login | |
| { | |
| path: 'login', |
This file contains hidden or 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
| canActivate( | |
| next: ActivatedRouteSnapshot, | |
| state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean { | |
| // Check if a 'currentUser' exists in the localStorage object | |
| // this will return undefined || false if there isn't | |
| if (localStorage['currentUsr']) { | |
| // User is logged in, let's let them through | |
| return true; | |
| } else { | |
| // user is not logged in, let's route them to the login page. |
This file contains hidden or 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
| login() { | |
| // We checked for validation in HTML so our credentials should not be blank. | |
| this.auth.login(this.credentials.email, this.credentials.pwd).subscribe((data) => { | |
| if (data.message === false) { | |
| // if invalid login, reset the form | |
| this.credentials.email = ''; | |
| this.credentials.pwd = ''; | |
| } else { | |
| // if we get here, there is no error, the return is valid | |
| // Let's first save the info into local storage for later use. We can parse this back |
This file contains hidden or 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
| function login(req, res) { | |
| // Find user by email | |
| User.findOne({ | |
| email: req.body.email | |
| }).then(user => { | |
| // Once we find the user, now let's pass the password from req.body to authenticate | |
| if (!user) { | |
| // Return false, user not even registered, but let's not tell them. | |
| res.send({ | |
| message: false |
This file contains hidden or 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
| /** | |
| * Authenticate - check if the passwords are the same | |
| * | |
| * @param {String} password | |
| * @param {Function} callback | |
| * @return {Boolean} | |
| * @api public | |
| */ | |
| authenticate(password, callback) { | |
| if (!callback) { |
This file contains hidden or 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="form-container"> | |
| <form name="form" class="loginForm" (ngSubmit)="f.form.valid && login()" #f="ngForm" novalidate> | |
| <div class="form-group"> | |
| <h2>User Login</h2> | |
| </div> | |
| <div class="form-group"> | |
| <label>Email</label> | |
| <input class="form-control" type="email" name="email" [(ngModel)]="credentials.email" required> | |
| </div> | |
| <div class="form-group"> |
This file contains hidden or 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
| function create(req, res) { | |
| // Define the new user, give the constructor the req.body containing all fields | |
| let newUser = new User(req.body); | |
| // if role not defined, lets give it a default user role, although our model should handle this | |
| newUser.role = 'user'; | |
| // Now lets save the user | |
| return newUser.save().then(function(user) { // then when the user saves | |
| // We will be returning only a few fields that we should need. | |
| res.json({ | |
| name: user.name, |
NewerOlder