create user on firebase
This commit is contained in:
parent
84d007ce7f
commit
4b791f53ca
3 changed files with 49 additions and 2 deletions
|
|
@ -83,14 +83,16 @@
|
|||
<div class="error-msg">
|
||||
@if (!password.valid && password.touched) {
|
||||
<p>You must enter a password.</p>
|
||||
}
|
||||
} @else { @if (registerData.password.length < 6 && password.touched) {
|
||||
<p>The password must consist of at least 6 characters</p>
|
||||
} }
|
||||
</div>
|
||||
<input
|
||||
type="passwordConfirm"
|
||||
id="passwordConfirm"
|
||||
name="passwordConfirm"
|
||||
#passwordConfirm="ngModel"
|
||||
placeholder="Password"
|
||||
placeholder="Confirm Password"
|
||||
class="custom-input"
|
||||
[(ngModel)]="registerData.passwordConfirm"
|
||||
required
|
||||
|
|
@ -107,6 +109,9 @@
|
|||
<div class="error-msg">
|
||||
@if (!passwordConfirm.valid && passwordConfirm.touched) {
|
||||
<p>You must enter a password.</p>
|
||||
} @if (registerData.password !== registerData.passwordConfirm &&
|
||||
registerData.password !== "" && registerData.passwordConfirm !== "") {
|
||||
<p>The passwords don't match!</p>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -121,6 +126,8 @@
|
|||
password.invalid ||
|
||||
!registerData.password ||
|
||||
sharedService.isBtnDisabled ||
|
||||
registerData.password.length < 6 ||
|
||||
registerData.password !== registerData.passwordConfirm ||
|
||||
!checkIfUserEmailIsValid(registerData.mail)
|
||||
"
|
||||
></app-form-btn>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ export class RegisterComponent {
|
|||
name: '',
|
||||
mail: '',
|
||||
password: '',
|
||||
color: '',
|
||||
initials: '',
|
||||
passwordConfirm: '',
|
||||
};
|
||||
|
||||
|
|
@ -41,6 +43,7 @@ export class RegisterComponent {
|
|||
this.sharedService.isBtnDisabled = true;
|
||||
if (ngForm.submitted && ngForm.form.valid) {
|
||||
//this.loginSerivce.register(this.registerData);
|
||||
console.log(this.registerData);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
signInWithEmailAndPassword,
|
||||
signInWithPopup,
|
||||
GoogleAuthProvider,
|
||||
Auth,
|
||||
} from 'firebase/auth';
|
||||
import { FirebaseService } from './firebase.service';
|
||||
import {
|
||||
|
|
@ -48,6 +49,39 @@ export class LoginService {
|
|||
});
|
||||
}
|
||||
|
||||
register(registerData: {
|
||||
name: string;
|
||||
mail: string;
|
||||
password: string;
|
||||
initials: string;
|
||||
color: string;
|
||||
}) {
|
||||
signInWithEmailAndPassword(
|
||||
getAuth(),
|
||||
registerData.mail,
|
||||
registerData.password
|
||||
)
|
||||
.then((userCredential) => {
|
||||
const user = userCredential.user;
|
||||
|
||||
const userDataToSave: User = {
|
||||
uId: user.uid,
|
||||
email: user.email || '',
|
||||
firstName: registerData.name || '',
|
||||
lastName: registerData.name || '',
|
||||
status: true,
|
||||
phone: '',
|
||||
initials: registerData.initials,
|
||||
color: registerData.color,
|
||||
lastLogin: new Date().getTime(),
|
||||
};
|
||||
this.createUserInFirestore(userDataToSave);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
googleLogin() {
|
||||
const auth = getAuth();
|
||||
const provider = new GoogleAuthProvider();
|
||||
|
|
@ -129,3 +163,6 @@ export class LoginService {
|
|||
localStorage.setItem('currentUserJOIN', JSON.stringify(userId));
|
||||
}
|
||||
}
|
||||
function createUserWithEmailAndPassword(auth: Auth, email: any, password: any) {
|
||||
throw new Error('Function not implemented.');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue