Skip to content

Commit aa125d3

Browse files
committed
TODO fix the error stuff. Reset from scratch if need be
1 parent ed6b62a commit aa125d3

11 files changed

+88
-76
lines changed

app/app.component.html

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313
</div>
1414
</div>
1515
<hr>
16-
<div class="small-12 medium-8 medium-centered columns">
17-
<div *ngIf="af.auth | async">You are logged in.</div>
18-
<div *ngIf="!(af.auth | async)">You're not logged in.</div>
19-
</div>
2016
</div>
21-
<p>
22-
<router-outlet></router-outlet>
23-
</p>
17+
<router-outlet></router-outlet>
18+
<hr>
19+
<div class="menu-centered">
20+
<ul class="menu">
21+
<li *ngIf="af.auth | async">LOGGED IN</li>
22+
<li *ngIf="!(af.auth | async)">NOT LOGGED IN</li>
23+
<li><a href="https://blog.khophi.co/angularfire2-authentication/" target="new">Read: AngularFire2 Authentication Article</a></li>
24+
</ul>
25+
</div>

app/auth/auth.component.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Component } from '@angular/core';
22
import { Router } from '@angular/router';
33

4-
import { AngularFire } from 'angularfire2';
4+
import { AngularFire, FirebaseAuth, AngularFireAuth } from 'angularfire2';
55

66
@Component({
77
templateUrl: 'app/auth/signup.component.html'
88
})
99

1010
export class SignupComponent {
11+
public error: any;
1112

1213
constructor(private af: AngularFire, private router: Router) { }
1314

@@ -26,6 +27,8 @@ export class SignupComponent {
2627
console.log(err);
2728
this.router.navigate(['/login']);
2829
})
30+
} else {
31+
this.error = 'Your form is invalid';
2932
}
3033
}
3134
}
@@ -35,7 +38,10 @@ export class SignupComponent {
3538
})
3639

3740
export class LoginComponent {
41+
public error: any;
42+
3843
constructor(private af: AngularFire, private router: Router) { }
44+
3945
onSubmit(formData) {
4046
if(formData.valid) {
4147
console.log(formData.value);
@@ -51,6 +57,22 @@ export class LoginComponent {
5157
console.log(err);
5258
this.router.navigate(['/dashboard']);
5359
})
60+
} else {
61+
this.error = 'Your form is invalid';
5462
}
5563
}
5664
}
65+
66+
@Component({
67+
templateUrl: 'app/auth/resetpassword.component.html'
68+
})
69+
70+
export class ResetpassComponent {
71+
constructor(private af: AngularFire) { }
72+
73+
onSubmit(formData) {
74+
if(formData.valid) {
75+
console.log('Submission worked');
76+
}
77+
}
78+
}

app/auth/auth.module.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FormsModule } from '@angular/forms';
33
import { CommonModule } from '@angular/common';
44

55
import { authRouting } from './auth.routing';
6-
import { LoginComponent, SignupComponent } from './auth.component';
6+
import { LoginComponent, SignupComponent, ResetpassComponent } from './auth.component';
77

88
@NgModule({
99
imports: [
@@ -13,7 +13,8 @@ import { LoginComponent, SignupComponent } from './auth.component';
1313
],
1414
declarations: [
1515
SignupComponent,
16-
LoginComponent
16+
LoginComponent,
17+
ResetpassComponent
1718
]
1819
})
1920
export class AuthModule { }

app/auth/auth.routing.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { ModuleWithProviders } from '@angular/core';
22
import { Routes, RouterModule } from '@angular/router';
33

4-
import { LoginComponent, SignupComponent } from './auth.component';
4+
import { LoginComponent, SignupComponent, ResetpassComponent } from './auth.component';
55

66
const appRoutes: Routes = [
77
{ path: 'login', component: LoginComponent },
8-
{ path: 'signup', component: SignupComponent }
8+
{ path: 'signup', component: SignupComponent },
9+
{ path: 'password-reset', component: ResetpassComponent }
910
];
1011

1112
export const authRouting: ModuleWithProviders = RouterModule.forChild(appRoutes);

app/auth/login.component.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<div class="row">
22
<div class="small-12 medium-8 medium-centered large-6 large-centered columns">
3+
<div class="callout alert" *ngIf="error">
4+
{{ error }}
5+
</div>
36
<h2>Login</h2>
47
<form #formData='ngForm' (ngSubmit)="onSubmit(formData)">
58
<div class="row">
69
<div class="small-12 columns">
710
<label> Enter email address
8-
<input type="text" name="email" placeholder="e.g [email protected]" (ngModel)="email" requred>
11+
<input type="email" name="email" placeholder="e.g [email protected]" (ngModel)="email" requred>
912
</label>
1013
</div>
1114
<div class="small-12 columns">
@@ -16,7 +19,7 @@ <h2>Login</h2>
1619
<div class="small-12 columns">
1720
<button type="submit" class="button" [disabled]="!formData.valid">Submit</button>
1821
<br/>
19-
<a routerLink="/signup">Don't have an account?</a>
22+
<a routerLink="/signup">Don't have an account?</a> &bull; <a routerLink="/password-reset">Forgotten password?</a>
2023
</div>
2124
</div>
2225
</form>

app/auth/resetpassword.component.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class="row">
2+
<div class="small-12 medium-8 medium-centered large-6 large-centered columns">
3+
<h2>Reset Password</h2>
4+
<form #formData='ngForm' (ngSubmit)="onSubmit(formData)">
5+
<div class="row">
6+
<div class="small-12 columns">
7+
<label> Enter email address
8+
<input type="email" name="email" placeholder="e.g [email protected]" (ngModel)="email" requred>
9+
</label>
10+
</div>
11+
<div class="small-12 columns">
12+
<button type="submit" class="button" [disabled]="!formData.valid">Submit</button>
13+
<br/>
14+
<a routerLink="/">Cancel</a>
15+
</div>
16+
</div>
17+
</form>
18+
</div>
19+
</div>

app/auth/signup.component.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<div class="row">
22
<div class="small-12 medium-8 medium-centered large-6 large-centered columns">
3+
<div class="callout alert" *ngIf="error">
4+
{{ error }}
5+
</div>
36
<h2>Sign Up</h2>
47
<form #formData='ngForm' (ngSubmit)="onSubmit(formData)">
58
<div class="row">

app/home/home.component.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<div class="row">
22
<div class="small-12 medium-6 medium-centered columns">
3-
<h3>Everyone can see this</h3>
3+
<div class="callout">
4+
<h3 class="lead">Welcome to AngularFire 2 Authentication</h3>
5+
<p>
6+
This page represents the landing page of your site, and public to everyone visiting.
7+
</p>
8+
9+
</div>
410
</div>
511
</div>

npm-debug.log

Lines changed: 0 additions & 45 deletions
This file was deleted.

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@
1111
},
1212
"license": "ISC",
1313
"dependencies": {
14-
"@angular/common": "2.0.0",
15-
"@angular/compiler": "2.0.0",
16-
"@angular/core": "2.0.0",
17-
"@angular/forms": "2.0.0",
18-
"@angular/http": "2.0.0",
19-
"@angular/platform-browser": "2.0.0",
20-
"@angular/platform-browser-dynamic": "2.0.0",
21-
"@angular/router": "3.0.0",
22-
"@angular/upgrade": "2.0.0",
23-
"angular2-in-memory-web-api": "0.0.20",
14+
"@angular/common": "2.0.1",
15+
"@angular/compiler": "2.0.1",
16+
"@angular/core": "2.0.1",
17+
"@angular/forms": "2.0.1",
18+
"@angular/http": "2.0.1",
19+
"@angular/platform-browser": "2.0.1",
20+
"@angular/platform-browser-dynamic": "2.0.1",
21+
"@angular/router": "3.0.1",
22+
"@angular/upgrade": "2.0.1",
23+
"angular2-in-memory-web-api": "0.0.21",
2424
"angularfire2": "^2.0.0-beta.5",
2525
"bootstrap": "^3.3.6",
2626
"core-js": "^2.4.1",
2727
"firebase": "^3.4.0",
2828
"foundation-sites": "^6.2.3",
2929
"reflect-metadata": "^0.1.3",
3030
"rxjs": "5.0.0-beta.12",
31-
"systemjs": "0.19.27",
31+
"systemjs": "0.19.39",
3232
"zone.js": "^0.6.23"
3333
},
3434
"devDependencies": {
35-
"concurrently": "^2.2.0",
35+
"concurrently": "^3.1.0",
3636
"lite-server": "^2.2.2",
3737
"typescript": "^2.0.2",
3838
"typings": "^1.3.2"

systemjs.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
main: './index.js',
4242
defaultExtension: 'js'
4343
},
44-
angularfire2: {
45-
main: 'bundles/angularFire2.umd.js',
46-
defautExtension: 'js'
47-
},
4844
firebase: {
4945
main: './firebase.js',
5046
defaultExtension: 'js'
5147
},
48+
angularfire2: {
49+
main: 'bundles/angularFire2.umd.js',
50+
defautExtension: 'js'
51+
},
5252
'angular2-toaster': {
5353
defaultExtension: 'js'
5454
}

0 commit comments

Comments
 (0)