-
What is the status of adding additional login methods? I want to authenticate to my email server. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As of today, there's no plan in supporting IMAP/POP3 login from the In case you want to login users using different protocols through the auth.login_user("[email protected]", "password") or the low-level API one: auth.ext.login_user(user_record) Since you can override routes in the auth exposer, you might end up with something like this: auth = Auth(app, db, user_model=User)
auth_routes = auth.module(__name__)
@auth_routes.login()
async def custom_login():
form = await Form({
'email': Field(validation={'is': 'email', 'presence': True}),
'password': Field('password')
})
if form.accepted:
# here goes the custom code to verify login with IMAP server
imap_logged_in = some_function_that_validates_the_login(
form.params.email, form.params.password
)
if imap_logged_in:
row = User.get(email=form.params.email)
if not row:
row = User.new(
email=form.params.email,
password=form.params.password
)
row.save()
auth.ext.login_user(row)
redirect(url("some_route"))
return {'form': form} |
Beta Was this translation helpful? Give feedback.
-
Thank you! That will do just fine. I looked through the source yesterday and that is pretty much what I was thinking, but your example will allow me to do it with more confidence. -Jim |
Beta Was this translation helpful? Give feedback.
As of today, there's no plan in supporting IMAP/POP3 login from the
auth
module. Some external work has been done aboutoauth2/oidc
, but an extension is not there yet.In case you want to login users using different protocols through the
auth
module in Emmett, you should write the appropriate code in your application (even using external libraries), and then manually create yourUser
record. Once you have a user, you can manually log that user in using the provided method:or the low-level API one:
Since you can override routes in the auth exposer, you might end up with something like this: