One Click Login
Take your app’s log-in form to the next level by letting your users sign in with a single tap of a button, avoiding complex passwords typing or password resets requests.
After tapping on the button the user will receive an email with an embedded smart link. Tapping on the email’s link, will take the user back to the app and loggin him in. For this to work, your app and your backend must integrate HOKO. Let’s start with your app.
Generating the lazy smart link for authentication
The user will enter his email and will tap on the Send Magic Link button.
This will request your server to send an email to the user’s account containing a lazy smart link
with the user’s authentication token, e.g. http://app.hoko.link/lazy?uri=%2Flogin%2Fq5w2e3r5t8y
.
Once the user opens the email and taps on the lazy smart link, it is going to request the generation of a smart link that will in fact redirect the user to your app.
Authenticating the token
For the application itself, all we need to do is map a login/:auth_token
route that calls a method
that is going to forward the authorization token to the backend to be validated.
[[Hoko deeplinking] mapRoute:@"login/:auth_token"
toTarget:^(HOKDeeplink *deeplink) {
// Validates the authentication token in the backend
[[LoginHelper sharedInstance] loginWithToken:deeplink.routeParameters[@"auth_token"]
onSuccess:^() {
// Set's the user access token
self.authToken = deeplink.routeParameters[@"auth_token"]
// Display the right view
[HOKNavigation presentViewController:[MyViewController new] animated:YES];
}];
}];
Hoko.deeplinking().mapRoute("login/:auth_token", toTarget: {
(deeplink: HOKDeeplink) -> Void in
// Validates the authentication token in the backend
LoginHelper.sharedInstance().loginWithToken(deeplink.routeParameters["auth_token"],
onSuccess: {
// Set's the user access token
self.authToken = deeplink.routeParameters[@"auth_token"]
// Display the right view
HOKNavigation.presentViewController(MyViewController(), animated: true)
})
})
If the response is positive, we can login the user and present the appropriate view. We are also going to save the current authorization token to be used on future requests.
More information
Need to know more about these subjects? Check the following pages for more information:
- Mapping routes with callbacks
- Generating smart links
- Lazy smart links
- Smart links with Metadata
- Utilities
Check our frequently asked questions or send us a message if you can’t find what you are looking for. We’re always glad to hear from you and answer all your questions.