-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Auto # after registration
Руслан Корнев edited this page Sep 8, 2019
·
7 revisions
# config/initializers/doorkeeper.rb
Doorkeeper.configure do
# ...
resource_owner_authenticator do
user = # ... the_code_that_finds_user, varies from app to app, warden.user works if you do Devise
if user
user
else
redirect_to(login_or_register_path(after_login_path: request.fullpath)
end
end
end
# ----
# in login controller
def login
user = the_code_to_login_user # varies from app to app
if user
login(user)
if params[:after_login_path] # this you need to make sure to pass from links to initial redirect path
redirect_to(params[:after_login_path])
end
else
# handle bad username and password
end
end
# in register user controller
def create
user = User.new(permitted_user_params)
if user.save
login(user)
if params[:after_login_path] # this you need to make sure to pass from links to initial redirect path
redirect_to(params[:after_login_path])
end
else
# handle invalid user
end
end
Check out for additional info: https://github.com/doorkeeper-gem/doorkeeper/issues/955
You may also want to return token in SPA application https://github.com/doorkeeper-gem/doorkeeper/issues/846