2009-12-28 50 views
2

只是想确认Nitrogen Authentication and Authorization API的用法。该API的描述是:Nitrogen Auth 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:用户(用户)的成功验证的用户?然后,我可以执行诸如检查undefined = wf:user()是否确认用户已通过身份验证以保护受限制的页面?同样,我会为用户设置角色等,然后​​我可以对角色执行验证。氮在背景中以某种方式将这些信息存储在背景中?

回答

0

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

+0

好的,谢谢你的信息。 – 2009-12-28 18:49:40

+0

知道任何好的氮气doc /教程? nitrogenproject.com上的文档是可以的,但要详细。 – 2009-12-28 18:54:10

+0

我有几个我写的,你可以在这里找到:http://jeremy.marzhillstudios.com/index.php/tag/nitrogen/ 除了氮工程的演示和文档是唯一的东西我真的知道。 – 2009-12-28 23:20:26