English 中文(简体)
铁路3 - 创建账户后自动在用户中进行伐木
原标题:Rails 3 - logging in a user automatically after creating the account

在我的<代码>用户_ Controller 页: 1 在成功<代码>发送_process电话后,我谨自动打上<代码>login。

Is this possible? In other language frameworks I would usually just call the login controller action direct from the signup_process action passing the username and password - but I think that is frowned upon in Rails.

取而代之的是post <代码>用户数据:login,由我的控制人采取行动?

这必须是共同的模式——我失踪了吗?

提前感谢!

最佳回答

不能确定你通过欺骗手段的含义,而是以某种方式。

class UsersController < ...
   def signup
      // Do some stuff
      do_login(username, password)
      // render or redirect as you wish
   end

   def login
     do_login(username,password)
     // render or redirect as you wish
   end

   private
   def do_login(username,password)
     // do the actual login processing 
     // can even render or redirect here if it s common to both setup and login
   end

end

这是你们想要的吗?

问题回答

标识行动如何?

Most likely, it sets something in the session indicating the user is logged in. You could do just that, after creating the user.

所谓控制者行动是没有道理的,因为它最有可能被视而不见。

请提供更多资料,说明如果你仍然认为需要这样做的话, log行动是什么。





相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签