2012-08-08 69 views
3

这似乎是一个愚蠢的问题,但我刚开始接触飞镖和需要验证这与您可能使用PHP与$ _SESSION数组做什么用户sesions ...飞镖中有会议吗?

所以我写一个基本服务器后端和前端,并且需要验证通过XMLHttpRequest进入的一些请求。后端根据给定的前端是否经过身份验证发回JSON。在某些情况下,前端可以更新DOM,但只有才能通过身份验证。

不知道如果我解释得很好...

任何意见将不胜感激!

谢谢!

+2

我搜索镖服务器端Web框架,这将落实会议,我发现这一点:https://github.com/lvivski/start可能有其他人。 – 2012-08-08 17:38:22

回答

2

会话是不应该成为任何语言的一部分的高级功能。你可以通过推动类似的东西来包含会话功能。

Map<String, int> sessions = {'abcdef12345' : 42}; // exists in e.g. datastore and is managed by an authentication routine 

    String authenticationToken = 'abcdef12345'; // comes from the request 
    if(sessions.containsKey(authenticationToken)) { 
    print('User ${sessions[authenticationToken]} is at least authenticated but might not have the appropriate rights to perform this operation.'); 
    } else { 
    print('Not authenticated.'); 
    } 
+0

好点 - 好吧,我会尝试通过POST。谢谢! – J99 2012-08-08 19:30:13

0

没事就好会议是内置的,但你可以检查出最近的谷歌API库飞镖来使用OAuth:

Google API Dart Client

+0

有趣 - 将检查了这一点。谢谢! – J99 2012-08-08 19:31:57

0

shelf_auth提供了一个很好的全自动JwtSessionHandler执行会话处理的解决方案shelf

var authMiddleware = authenticate([new RandomAuthenticator()], 
     new JwtSessionHandler('super app', 'shhh secret', testLookup));