Authentication 氮气认证API的正确用法是什么?

Authentication 氮气认证API的正确用法是什么?,authentication,erlang,authorization,nitrogen,Authentication,Erlang,Authorization,Nitrogen,只是想确认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(Ro

只是想确认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()
,以判断用户是否已通过身份验证以保护受限制的页面?类似地,我会为用户设置角色,等等,然后我也可以对角色执行验证?氮气会在后台为我存储这些信息吗?

你说得对。氮气会话只是一个存储会话信息的erlang进程。用法与您描述的一样。您可以查询以查看用户是否已登录,还可以设置和查询用户的角色。任何更复杂的事情你都得自己做。

你是对的。氮气会话只是一个存储会话信息的erlang进程。用法与您描述的一样。您可以查询以查看用户是否已登录,还可以设置和查询用户的角色。任何更复杂的事情你都得自己做。

知道什么好的氮气文档/教程吗?NitronyProject.com上的文档还可以,但是非常详细。我写了一些文档,你可以在这里找到:除此之外,关于NitronyProject的演示和文档是我真正了解的唯一内容。知道任何好的Nitron文档/教程吗?NitronProject.com上的文档还可以,但是太详细了。我写了几个文档,你可以在这里找到:除此之外,我只知道NitronProject上的演示和文档。