Authlogic no credentials provided

1.3k views Asked by At

I'm using MongoMapper, Authlogic and these codes too, https://gist.github.com/444888/e8b28196c4f4452a06b89d566a6a245eae1e9d92.

I'm having trouble when I'm skipping the authentication to log the user in directly. According to the Authlogic, I just need to input these line of codes:

user = User.find(1234)    
UserSession.create(user, true)

and it will automatically logs in the user. But I always got this output:

#<UserSession: no credentials provided>

Is there any configuration that I need to fix or change? Like in UserSession.

Thanks in advance.

1

There are 1 answers

2
Jesse Wolgamott On BEST ANSWER

This is how I log people in through an API token using mongomapper/authlogic

@session = UserSession.new(User.find_by_single_access_token(params[:token]))
@session.save

This is a dupe of the answer I gave over on authlogic UserSession.create(@user) giving unauthorized_record

In that answer, the original poster stated "persistence_token was not being set when the user object was saved!"