Kevin
Kevin

Reputation: 1614

Rails Devise parameter

Is there a way in devise that i can simply send in a url that contains a users password name or email and it registers the user or starts a new sessions, rather than actually logging in through the form (I want to simply send in username and password and login the user or register him)

Upvotes: 0

Views: 204

Answers (3)

Gareth
Gareth

Reputation: 138082

Take a look at Devise's "TokenAuthenticable" module which gives a user a unique login key, although it's not the same as their email or password.

Upvotes: 1

colinm
colinm

Reputation: 4288

This is a generally a bad idea for numerous reasons, but if your use case demands it, there's nothing stopping you from doing it.

Since Devise user records are just standard Active Record records, you can use finders on them like any other object:

u = User.find(:first, :conditions => {:username => 'foo'})

And create them mostly like any other object:

u = User.new
u.username = 'jsmith'
u.password = 'password'
u.password_confirmation = 'password'
u.save

Devise provides a valid_password? instance method you can use to check the password of a retrieved object:

u.valid_password?('monkey')

And from any controller, you can call sign_in with a retrieved user object:

sign_in(:user, u)

Upvotes: 2

antiqe
antiqe

Reputation: 1124

You can do all that things without using devise. In any other case you should rewrite devise security system.

Upvotes: 0

Related Questions