public async Task <string> CreateChatSession() { string userId = User.Identity.GetUserId(); var user = await UserManager.FindByIdAsync(userId); int ret = await ChatModel.CreateSessionWithUser(); // ret += await ChatModel.SingUp(); string passwd = await ChatModel.SignUpForChat(user); return(passwd); }
public async Task <LoginReturn> FacebookLoginHub([FromBody] FacebookLoginModel model) { LoginReturn ret = new LoginReturn(); if (!ModelState.IsValid) { ret.errors.Add("ModelState Error"); ret.success = false; //return BadRequest(ModelState); return(ret); } var user = await UserManager.FindByNameAsync(model.FacebookId); if (user == null) { RegisterFacebookModel m = new RegisterFacebookModel(); m.FacebookAccessToken = model.FacebookAccessToken; var reg = await RegisterWithFacebook(m); if (reg.success == false) { ret.success = false; ret.errors = reg.errors; return(ret); } user = await UserManager.FindByNameAsync(model.FacebookId); await ChatModel.CreateSessionWithUser(); await ChatModel.SignUpForChat(user); // await ChatModel.SignUpForChat(user); } ///Must be registered by now ///Refresh Tokena if (!await UserManager.CheckPasswordAsync(user, model.FacebookAccessToken)) { RegisterFacebookModel m = new RegisterFacebookModel(); m.FacebookAccessToken = model.FacebookAccessToken; var reg = await ChangeFacebookAccessToken(m); if (reg.success == false) { ret.success = false; ret.errors = reg.errors; return(ret); } } return(ret); }