只想确认Nitrogen Authentication and Authorization API的使用情况。 API的描述是:
wf:user() -> User or 'undefined'
Return the user value that was previously set by wf:user(User)
wf:user(User) -> ok
Set the user for the current session.
wf:clear_user() -> ok
Same as wf:user(undefined).
wf:role(Role) -> 'true' or 'false'
Check if the current user has a specified role.
wf:role(Role, IsInRole) -> ok
Set whether the current user is in a specified role.
wf:clear_roles() -> ok
Remove the user from all roles.
要使用此API,我首先会针对存储凭据的数据库验证用户登录,然后将wf:user(User)设置为成功通过身份验证的用户?然后,我可以检查是否undefined = wf:user()
来判断用户是否已经过身份验证以保护受限制的页面?同样我会为用户设置角色等,然后我也可以对角色进行验证?而且氮会以某种方式在背景中将这些信息存储在会话中吗?
答案 0 :(得分:0)