Skip to content

Commit ce620e8

Browse files
committed
initial commit
0 parents commit ce620e8

40 files changed

+7604
-0
lines changed

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
11+
# Directory for instrumented libs generated by jscoverage/JSCover
12+
lib-cov
13+
14+
# Coverage directory used by tools like istanbul
15+
coverage
16+
17+
# nyc test coverage
18+
.nyc_output
19+
20+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21+
.grunt
22+
23+
# node-waf configuration
24+
.lock-wscript
25+
26+
# Compiled binary addons (http://nodejs.org/api/addons.html)
27+
build/Release
28+
29+
# Dependency directories
30+
node_modules
31+
jspm_packages
32+
typings
33+
34+
# Optional npm cache directory
35+
.npm
36+
37+
# Optional REPL history
38+
.node_repl_history
39+
40+
# Generated files
41+
dist

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2018 Jason Watmore
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# angular-8-registration-login-example
2+
3+
Angular 8 User Registration and Login Example with Webpack 4
4+

package-lock.json

Lines changed: 6715 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "angular-8-registration-login-example",
3+
"version": "1.0.0",
4+
"repository": {
5+
"type": "git",
6+
"url": "https://github.com/cornflourblue/angular-8-registration-login-example.git"
7+
},
8+
"scripts": {
9+
"build": "webpack --mode production",
10+
"start": "webpack-dev-server --mode development --open"
11+
},
12+
"license": "MIT",
13+
"dependencies": {
14+
"@angular/animations": "^8.0.0",
15+
"@angular/cdk": "^8.0.0",
16+
"@angular/common": "^8.0.0",
17+
"@angular/compiler": "^8.0.0",
18+
"@angular/core": "^8.0.0",
19+
"@angular/forms": "^8.0.0",
20+
"@angular/material": "^8.0.0",
21+
"@angular/platform-browser": "^8.0.0",
22+
"@angular/platform-browser-dynamic": "^8.0.0",
23+
"@angular/router": "^8.0.0",
24+
"core-js": "^3.1.3",
25+
"rxjs": "^6.3.3",
26+
"zone.js": "^0.9.1"
27+
},
28+
"devDependencies": {
29+
"@types/node": "^12.0.4",
30+
"angular2-template-loader": "^0.6.2",
31+
"css-loader": "^2.1.1",
32+
"html-webpack-plugin": "^3.2.0",
33+
"mini-css-extract-plugin": "^0.7.0",
34+
"raw-loader": "^1.0.0",
35+
"style-loader": "^0.23.1",
36+
"ts-loader": "^6.0.1",
37+
"typescript": "^3.1.3",
38+
"webpack": "^4.32.2",
39+
"webpack-cli": "^3.1.2",
40+
"webpack-dev-server": "^3.1.10"
41+
}
42+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div *ngIf="message" [ngClass]="{ 'alert': message, 'alert-success': message.type === 'success', 'alert-danger': message.type === 'error' }">{{message.text}}</div>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component, OnInit, OnDestroy } from '@angular/core';
2+
import { Subscription } from 'rxjs';
3+
4+
import { AlertService } from '@/_services';
5+
6+
@Component({
7+
selector: 'alert',
8+
templateUrl: 'alert.component.html'
9+
})
10+
11+
export class AlertComponent implements OnInit, OnDestroy {
12+
private subscription: Subscription;
13+
message: any;
14+
15+
constructor(private alertService: AlertService) { }
16+
17+
ngOnInit() {
18+
this.subscription = this.alertService.getMessage().subscribe(message => {
19+
this.message = message;
20+
});
21+
}
22+
23+
ngOnDestroy() {
24+
this.subscription.unsubscribe();
25+
}
26+
}

src/app/_components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './alert.component';

src/app/_guards/auth.guard.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { Injectable } from '@angular/core';
2+
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
3+
4+
import { AuthenticationService } from '@/_services';
5+
6+
@Injectable({ providedIn: 'root' })
7+
export class AuthGuard implements CanActivate {
8+
constructor(
9+
private router: Router,
10+
private authenticationService: AuthenticationService
11+
) {}
12+
13+
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
14+
const currentUser = this.authenticationService.currentUserValue;
15+
if (currentUser) {
16+
// authorised so return true
17+
return true;
18+
}
19+
20+
// not logged in so redirect to login page with the return url
21+
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
22+
return false;
23+
}
24+
}

src/app/_guards/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './auth.guard';

0 commit comments

Comments
 (0)