Frexuz
Frexuz

Reputation: 4933

Rails + Devise - Authenticate method in custom controller

Is there an equivalent to the Authenticate method from RestfulAuthentication, like so?

@user = User.authenticate(@email, @password)

I have a custom controller i use for authenticating a mobile request, where the email/password come from the url, like http://localhost:3000/iphone/auth/[email protected]/mypassword

Upvotes: 10

Views: 5132

Answers (1)

Matteo Alessani
Matteo Alessani

Reputation: 10412

Maybe you can use something like this:

user = User.find(:first, :conditions => ["email = ?", @email])
user.valid_password?(@password) unless user.nil?

Upvotes: 19

Related Questions