I am working on project that is using doorkeeper
gem.
I have setup everything successfully.
Now what i want to do is to logged the user in after successful registration.I am using sorcery
gem for authentication .
My registration process is working fine and i am getting access_token
from doorkeeper.
But i cant't logging in the user with doorkeeper
gem.
Here is my users_controller.rb
def create
profile = Profile.new(params.permit(:birth_date, :phone_number))
user = profile.build_user(params.permit(:first_name, :last_name, :email, :password))
if profile.save
@access_token = Doorkeeper::AccessToken.create!(
resource_owner_id: user.id,
application_id: doorkeeper_token.application_id,
use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?,
expires_in: Doorkeeper.configuration.access_token_expires_in
)
#This line is for authentication provided by sorcery gem
@user = User.authenticate( params[:email], params[:password])
else
error!(:unprocessable_entity, metadata: { details: profile.errors })
end
end
I have tried using doorkeeper provided resource_owner_from_credentials
method at my users_controller.rb for login but still i failed like below:
Doorkeeper.resource_owner_from_credentials do
User.authenticate(params[:email], params[:password])
end
Can any tell me how to login the user after successful registration with doorkeeper and sorcery gem.
thank you very much.