This is the code for my ajax call
var data = {user: {password: password, email: email}};
$.post('auto_login',data,function(res){
if(res.success){
// successfully logged in
}
else{
// failed log in
}
});
This is the code in my controller
def auto_login
@user = parmas[:user]
# how do i invoke login here...
# res = Sessions.new(@user)
# x = true if res.save
respond_to do |format|
format.json{ render :json => { :success => x } }
end
end
I am doing this because I have a button which if a unregistered user clicks it will pop-up a modal window which ask for login info or register to the site. After the user fills up the required information, and if the system recognize that the data are valid, it will automatically redirect the user to a particular url.
Any help will do.
Thank you.