librelist archives

« back to archive

login的问题

login的问题

From:
Uno Young
Date:
2012-07-12 @ 03:40
如果采取instance:login()的方式,则不应该调用authenticate函数再进行判断,直接在login函数里面就可以判断了,
可做如下更改

login = function (self, params)
I_AM_CLASS_OR_INSTANCE(self)
-- make instance can use this login
local user
if isInstance(self) then
user = self
else
if not params['username'] or not params['password'] then return nil end
authed, user = self:authenticate(params)
if not authed then return nil end
end
 Session:setKey('user_id', self:classname() + ':' + user.id)
Session:userHash(user, req.session_id)
 req.user = user
return user
end;

Re: [bamboo] login的问题

From:
Tang Daogang
Date:
2012-07-12 @ 04:29
已合并。

On Thu, Jul 12, 2012 at 11:40 AM, Uno Young <littlehaker@gmail.com> wrote:

> 如果采取instance:login()的方式,则不应该调用authenticate函数再进行判断,直接在login函数里面就可以判断了,
> 可做如下更改
>
> login = function (self, params)
> I_AM_CLASS_OR_INSTANCE(self)
>  -- make instance can use this login
> local user
>  if isInstance(self) then
> user = self
>  else
> if not params['username'] or not params['password'] then return nil end
>  authed, user = self:authenticate(params)
> if not authed then return nil end
>  end
>  Session:setKey('user_id', self:classname() + ':' + user.id)
>  Session:userHash(user, req.session_id)
>  req.user = user
>  return user
> end;
>



-- 
Nothing is impossible.