ruby on rails - How to generate reset password token -


i using devise gem authentication.

in application admin create users, want user's reset password link when admin creates users.

this action:-

def create    @user = user.new(user_params)    @user.password = '123123123'    @user.password_confirmation = '123123123'    if @user.save          @user.update_attributes(:confirmation_token => nil,:confirmed_at => time.now,:reset_password_token => (0...16).map{(65+rand(26)).chr}.join,:reset_password_sent_at => time.now)        usermailer.user_link(@user).deliver        redirect_to users_path      else     render :action => "new"    end end 

this link reset user's password

but getting reset password token invalid when open link , update password.

you can use user.send_reset_password_instructions that.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -