Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- createUser({ body }, res) {
- auth.createUser({
- email: body.email,
- password: body.password,
- displayName: body.displayName || '',
- photoURL: body.photoURL || DEFAULT_PHOTO_URL,
- })
- .then((userRecord) => {
- console.log('Successfully created new user:', userRecord);
- res.send(userRecord);
- })
- .catch((error) => {
- console.log('Error creating new user:', error);
- res.send(error);
- });
- }
- createUser(properties: Object): Observable<any> {
- const body = JSON.stringify(properties);
- const url = 'api/user';
- const headers = new Headers({ 'Content-Type': 'application/json' });
- const options = new RequestOptions({ headers: headers });
- return this.http
- .post(url, body, options)
- .map((res: Response) => res.json())
- .catch((error: any) => Observable.throw(error.json()));
- }
- registerWithEmailAndPassword(): void {
- const properties = {
- 'displayName': this.registerForm.get('firstname').value.toString() + ' ' + this.registerForm.get('lastname').value.toString(),
- 'email': this.registerForm.get('email').value.toString(),
- 'password': this.registerForm.get('password').value.toString()
- };
- this.authService.createUser(properties).subscribe(
- res => {
- console.log('res: ', res);
- }, error => {
- console.error('error: ', error);
- }
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement