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

Is there a way to use my own method to log users in and generate SESSION_TOKEN? #48

Open
artemsmikh opened this issue Jan 16, 2018 · 1 comment

Comments

@artemsmikh
Copy link

Hi, I was wondering if there is a way to avoid the default login system provided by Tapglue and use my own code for that. For example, I'd like to authenticate users using their phone numbers instead of emails and passwords. I have a service that checks and verifies phone numbers and all I need is to have some method (like login) where I could pass a phone number and a verification code and then this method would check the code using that verification service and, in case of success, generate SESSION_TOKEN and return it to the client.

The docs says:

If you decide to use your own user management get in touch with us and we show you how to create the SESSION_TOKEN from your backend.

So, do you think is that possible?

@artemsmikh artemsmikh changed the title Is there a way to use my own to log in users and generate SESSION_TOKEN? Is there a way to use my own method to log users in and generate SESSION_TOKEN? Jan 16, 2018
@xla
Copy link
Member

xla commented Jan 16, 2018

Hej @artemsmikh thanks for bringing this up. Unfortunately we removed the pure backend integrations when we made we made the code open-source, which is the integration that is referred to.

There are ways to achieve this with a small binary you could run yourself, by pulling in the session creation code:

snaas/core/user.go

Lines 748 to 776 in 4347b6b

ss, err := sessions.Query(currentApp.Namespace(), session.QueryOptions{
DeviceIDs: []string{
deviceID,
},
Enabled: &defaultEnabled,
UserIDs: []uint64{
u.ID,
},
})
if err != nil {
return err
}
var s *session.Session
if len(ss) > 0 {
s = ss[0]
} else {
s, err = sessions.Put(currentApp.Namespace(), &session.Session{
DeviceID: deviceID,
Enabled: true,
UserID: u.ID,
})
if err != nil {
return err
}
}
u.SessionToken = s.ID

Maybe if you could describe the exact flow and what component calls what we can work it out.

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

No branches or pull requests

2 participants