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

Complete registration #17

Open
blackotruck opened this issue Jan 11, 2015 · 5 comments
Open

Complete registration #17

blackotruck opened this issue Jan 11, 2015 · 5 comments

Comments

@blackotruck
Copy link

Greetings, awesome library!

Now, i got a question regarding the complete registration process.

if (user.hasValidatedEmail) {
  wrappedService.userRole = userRoles.registered;
} else {
   wrappedService.userRole = userRoles.invalidEmail;
   $state.go('app.nagscreen');
}

Right now i'm not changing the state, as i use a lightbox to put the validation code. My problem is, after the validation code is sent, i need to update the user 'valid_email' to ', so i can now access the dashoboard, but i don't understand how could i do this... Any idea?

@colthreepv
Copy link
Owner

Let me understand clearly: you need something like a server-sent event that updates the informations on angularjs, when your user validates the code.

This can be done in a lot of ways, googling server-sent events will blow your mind, usually depends how much time intercours between the action: code is sent -> code is validated

If the user closes the page and then re-opens it, the page refresh should update the userRole, if you want the userRole updated also while having the page open, you should setup something like a long-poll API (easiest way), your application will make an AJAX request to your server and wait for some update.

The update can be processed using loginHandler or anything other function that updates the user Object

Hope I have been useful

@blackotruck
Copy link
Author

This: "The update can be processed using loginHandler"
What i want to know is how to update the user from the loginHandler. i already sent the data from the server to the app, and this returns the new user data (exactly as before only that now has validated email true). The setUser(user) function es public?... if so, then the questions is already answered hehehe

EDIT: BTW that was a super quick response... and on a sunday!!! You rock bro!

@colthreepv
Copy link
Owner

I just have no life on sunday ;)

I think loginHandler was meant mainly to setup an userToken, from what I understand your users are already logged in, just they need an update on their status.

AFAIK you could just inject in your controller the loginService (as is done here), when the Ajax reply is done you can assign a new userRole to loginService.userRole manually.

That should work, if userRole change needs to get propagated to some scope you can use:

$scope.$apply(function (scope) {
  loginService.userRole = userRoles.goodUser;
});

But that depends how you read the informations from the service :)

@blackotruck
Copy link
Author

Mr Gamer! it's me again! hehe.... well i got another issue here. After i send input the code, i send the data to de server an validate the email properly, then i do a $state.go('app.dashboard'), so an statechagenstart event is emmited and the app redirects to the dashboard but, the top menu continues to show the login instead of the proper options for logged users.

So what i want is to login the user after sign up, but ask for validation, and only show the users menu after the validation (without reloading)

@colthreepv
Copy link
Owner

Okey, this is doable, the user menu in this demo follows loginService.isLogged property, as seen in the index.html

Maybe you don't update this property correctly after the user gets validated, in the example loginHandler function there is a line where isLogged is set to true.
This should be done also in your implementation, or something alike

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