Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login problems #16

Open
Ridermansb opened this issue Nov 18, 2015 · 4 comments
Open

Login problems #16

Ridermansb opened this issue Nov 18, 2015 · 4 comments

Comments

@Ridermansb
Copy link

On some occasions the sdk returns false for emailConfirmed, even though I have already been confirmed.

In editor is correct!

login: function (email, password) {
       if (user.isLogged()) {
           this.logout();
       }

       user = new Stamplay.User().Model;
       return user.login(email, password).then(function () {
           return user.currentUser().then(function () {
               var givenRole = user.get('givenRole');

               // Most cases, emailVerified property in Stamplay are true, but here return false ?
               var emailVerified = user.get('emailVerified');
               if (!emailVerified) {
                   console.error(email, ' was not verified');
                   return false;
               }
               return user.isLogged();
           });
       });
   },
@criroselli
Copy link
Contributor

Hey,

I not able to reproduce this error with the code that you have written here. Can give me more details about this ?

Thanks

@Ridermansb
Copy link
Author

Hi @criroselli , sorry for delay.

I`m have a Auth service register as folow:

.factory('Auth', AuthService)

And in my controller, when click in logon button..

  Auth.login($scope.email, $scope.senha)
      .then(function (wasSuccess) {
          if (wasSuccess) {
              $state.go('user.home', {});
          } else {
              $mdToast.show(
                  $mdToast.simple()
                      .content('Error when try to logon.').position('top right')
              );
          }

      }).catch(function (err) {
          $mdToast.show(
              $mdToast.simple()
                  .content(err.responseText).position('top right')
          );
      }).done(function () {

the login function is ..

login: function (email, password) {
       if (user.isLogged()) {
           this.logout();
       }

       user = new Stamplay.User().Model;
       return user.login(email, password).then(function () {
           return user.currentUser().then(function () {
               var givenRole = user.get('givenRole'); // THIS IS UNDEFINED

               // Most cases, emailVerified property in Stamplay are true, but here return false ?
               var emailVerified = user.get('emailVerified');
               if (!emailVerified) {
                   console.error(email, ' was not verified');
                   return false;
               }
               return user.isLogged();
           });
       });
   },

The same code above

Just for the records.. the givenRole is undefined.

Right now I'm adding a angular-stamplay, maybe this resolves the problem.

@Ridermansb
Copy link
Author

I build a demo app on github, maybe it can help to understand.

This is a simple app, to made a login with

Username> My current email address
Password> 12345

@Ridermansb
Copy link
Author

One problem I've noticed is that user.currentUser() does not correctly fulfill the user data when called after user.login() function.
Perhaps this is because the function does not save th login session.

What did I do to solve this problem (issue 1) was soon after login, save the user information.

This code mention above can be used for demonstration propose, maybe can you help me fixin same issues :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants