Async login

This commit is contained in:
Blake Bourque
2015-06-24 18:31:17 -04:00
parent 068d53279e
commit bed881b279
3 changed files with 53 additions and 28 deletions
@@ -10,29 +10,21 @@ namespace PlexView
{
public UserMod () : base("/api")
{
//When the users requests to login
Post["/login"] = parameters =>
{
//process a login request
//parese their credentials
Creds creds = this.Bind<Creds>();
User client = ClientMgr.Instance.NewUser(creds);
//initiate login process
Guid sessionID = ClientMgr.Instance.NewUserLogin(creds);
//tell them that we have started login
Hashtable msg = new Hashtable();
msg.Add("status", "login begin");
msg.Add("sessionID", sessionID);
return msg;
if (ClientMgr.Instance.Login(client))
{
Hashtable msg = new Hashtable();
msg.Add("status", "success");
msg.Add("motd", client.Network.LoginMessage);
msg.Add("sessionID", client.sessionID);
return msg;
}
else
{
Hashtable msg = new Hashtable();
msg.Add("status", "fail");
msg.Add("motd", client.Network.LoginMessage);
msg.Add("sessionID", client.sessionID);
return msg;
}
};
Post["/logout"] = parameters =>