Programmatically log a user in (outside of Rodauth routes) #483
aguynamedben
started this conversation in
General
Replies: 1 comment 2 replies
-
You may want to use Here's what def autologin_session(autologin_type)
login_session('autologin')
set_session_value(autologin_type_session_key, autologin_type)
end Here's what def login(auth_type)
@saved_login_redirect = remove_session_value(login_redirect_session_key)
transaction do
before_login
login_session(auth_type)
yield if block_given?
after_login
end
require_response(:_login_response)
end As you can see, both call def login_session(auth_type)
update_session
set_session_value(authenticated_by_session_key, [auth_type])
end Not sure if you were aware of it, but you may want to consider using rodauth-omniauth instead of custom code. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What's the recommended way to programmatically log a user in?
Is it something like this?
Can the
autologin_type
value passed torodauth.autologin_session
be any arbitrary string? Is this value stored in the session cookie or something like that? I was expecting a simple API similar to Devise, i.e.sign_in(user)
. This seems to be working, but it was a struggle reading through the guides, API docs, and examples.Use case: I'm programmatically creating Accounts from an OAuth response (OmniAuth auth_hash). I have the right Account, I'm just not sure which rodauth API call(s) log the user in. Right now in my controller I have:
Beta Was this translation helpful? Give feedback.
All reactions