-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Auto sign up after registration
Nikita Bulai edited this page Feb 5, 2018
·
7 revisions
# config/doorkeeper
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.full_path)
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