From e5a7a7e76229b63d8ae4f8def475e27c951d6995 Mon Sep 17 00:00:00 2001 From: Damien Date: Fri, 29 Sep 2017 10:23:44 +0100 Subject: [PATCH 1/2] I added user name to signup form --- package-lock.json | 18 ++++++------- src/app/ui/user-form/user-form.component.html | 26 ++++++++++--------- src/app/ui/user-form/user-form.component.ts | 5 +++- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/package-lock.json b/package-lock.json index 216038fa..3716c277 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7858,6 +7858,15 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "dev": true, + "requires": { + "safe-buffer": "5.1.1" + } + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -7869,15 +7878,6 @@ "strip-ansi": "3.0.1" } }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "dev": true, - "requires": { - "safe-buffer": "5.1.1" - } - }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/src/app/ui/user-form/user-form.component.html b/src/app/ui/user-form/user-form.component.html index 69be4bdb..f6c192a6 100644 --- a/src/app/ui/user-form/user-form.component.html +++ b/src/app/ui/user-form/user-form.component.html @@ -1,21 +1,25 @@ - -
+

New User Signup

Already Registered?


- +
{{ formErrors.email }}
+ + + +
+ {{ formErrors.displayName }} +
+ - +
{{ formErrors.password }} @@ -30,23 +34,21 @@

New User Signup

-
+

Existing User Login

New User?


- +
{{ formErrors.email }}
- +
{{ formErrors.password }} @@ -60,4 +62,4 @@

Existing User Login

Reset requested. Check your email instructions.

- + \ No newline at end of file diff --git a/src/app/ui/user-form/user-form.component.ts b/src/app/ui/user-form/user-form.component.ts index 3e5db5e3..8f2d5c48 100644 --- a/src/app/ui/user-form/user-form.component.ts +++ b/src/app/ui/user-form/user-form.component.ts @@ -40,7 +40,8 @@ export class UserFormComponent implements OnInit { } signup(): void { - this.auth.emailSignUp(this.userForm.value['email'], this.userForm.value['password']) + this.auth.emailSignUp(this.userForm.value['email'], + this.userForm.value['password']) } login(): void { @@ -65,6 +66,8 @@ export class UserFormComponent implements OnInit { Validators.maxLength(25) ] ], + 'displayName': ['', [ + ]] }); this.userForm.valueChanges.subscribe(data => this.onValueChanged(data)); From 639beb83dd5ad18b9229e2be134737fade6b3b59 Mon Sep 17 00:00:00 2001 From: Damien Date: Fri, 29 Sep 2017 10:29:24 +0100 Subject: [PATCH 2/2] I added signup with username, email and password --- src/app/core/auth.service.ts | 20 ++++++++++++++++++++ src/app/ui/user-form/user-form.component.ts | 5 +++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/app/core/auth.service.ts b/src/app/core/auth.service.ts index 4338b112..4362f687 100644 --- a/src/app/core/auth.service.ts +++ b/src/app/core/auth.service.ts @@ -108,6 +108,26 @@ export class AuthService { .catch(error => console.log(error)); } + emailSignUpWithDisplayName(email:string, password:string, displayName:string) { + return this.afAuth.auth.createUserWithEmailAndPassword(email, password) + .then((user) => { + //Add a display name to the user. + user.updateProfile({ + displayName: displayName + }).then(() => { + // Update successful + this.authState = user + }); + + this.updateUserData() + }) + .catch(error =>{ + console.log(error); + //THrow the exception which results when user signsup + throw(error); + }); + } + emailLogin(email: string, password: string) { return this.afAuth.auth.signInWithEmailAndPassword(email, password) .then((user) => { diff --git a/src/app/ui/user-form/user-form.component.ts b/src/app/ui/user-form/user-form.component.ts index 8f2d5c48..74b1bbb5 100644 --- a/src/app/ui/user-form/user-form.component.ts +++ b/src/app/ui/user-form/user-form.component.ts @@ -40,8 +40,9 @@ export class UserFormComponent implements OnInit { } signup(): void { - this.auth.emailSignUp(this.userForm.value['email'], - this.userForm.value['password']) + this.auth.emailSignUpWithDisplayName(this.userForm.value['email'], + this.userForm.value['password'], + this.userForm.value['displayName']) } login(): void {