Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- loginWithEmail() {
- const mail = 'alexander2@gmail.com';
- const pass = '1234567890';
- const login = from(this.afAuth.auth.signInWithEmailAndPassword(mail, pass));
- login.subscribe(() => {
- this.router.navigateByUrl('home/main');
- }, err => {
- const error = JSON.stringify(err);
- // console.log('error login: ' + err);
- if (error) {
- if (error.indexOf('no user') > -1 || error.indexOf('email address') > -1) {
- // this.user_error = true;
- // this.pass_error = true;
- }
- if (error.indexOf('password') > -1) {
- // this.user_error = false;
- // this.pass_error = true;
- }
- }
- }
- )
- login.pipe(
- switchMap((firebaseUser: firebase.User) => {
- const user = <firebase.User>firebaseUser;
- console.log(user);
- return from((user.getIdToken()));
- }),
- switchMap(idToken => {
- console.log('idtoken firebase', idToken);
- return this.http.get('http://localhost:4949/auth/user')
- })
- ).subscribe(data => {
- console.log('data user', data);
- this.router.navigateByUrl('home/main');
- }, err => {
- const error = JSON.stringify(err);
- // console.log('error login: ' + err);
- if (error) {
- if (error.indexOf('no user') > -1 || error.indexOf('email address') > -1) {
- // this.user_error = true;
- // this.pass_error = true;
- }
- if (error.indexOf('password') > -1) {
- // this.user_error = false;
- // this.pass_error = true;
- }
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement