public ActionResult ChangePassword() { string logInDataFromClient = Request[Consts.RequestIdForUserData]; bool isChangePassSuccesed = false; string response = ""; try { LogInMessage UserObject = JsonConvert.DeserializeObject <LogInMessage>(logInDataFromClient); if (ChangePassword(CheckUserLoginData(UserObject.username, UserObject.password), UserObject.username, UserObject.newPassword)) { isChangePassSuccesed = true; } else { isChangePassSuccesed = false; } } catch { } response = JsonConvert.SerializeObject(isChangePassSuccesed); return(Content(response)); }
public async Task <(bool result, string key)> LogInAsync([NotNull] string login) { if (login == null) { throw new ArgumentNullException(nameof(login)); } var message = new LogInMessage() { Login = login }; var deSerializedData = await GetDataAsync(message); switch (deSerializedData) { case ErrorMessage errorMessage: MessageBox.Show(errorMessage.Error); return(false, null); case SessionKeyMessage sessionKeyMessage: MessageBox.Show(sessionKeyMessage.ToString()); return(true, sessionKeyMessage.SessionKey); default: throw new Exception(); } }
//Authentication methods start public ActionResult CreateNewUser() { string createUserDataFromClient = Request[Consts.RequestIdForUserData]; bool createUserSuccesed = false; string response; try { LogInMessage UserObject = JsonConvert.DeserializeObject <LogInMessage>(createUserDataFromClient); if (IsUserExistInDatabase(UserObject.username)) { createUserSuccesed = false; } else { CreateUser(UserObject.username, UserObject.password); createUserSuccesed = true; } } catch { } response = JsonConvert.SerializeObject(createUserSuccesed); return(Content(response)); }
public ActionResult GetUserInstance() { string requestForUserInstance = Request[Consts.RequestIdForUserData]; string response = ""; ChatUser currentUser = null; try { LogInMessage UserObject = JsonConvert.DeserializeObject <LogInMessage>(requestForUserInstance); if (IsUserExistInDatabase(UserObject.username)) { currentUser = GetCurrentUserInstance(UserObject.username); } else { currentUser = null; } } catch { } response = JsonConvert.SerializeObject(currentUser); return(Content(response)); }
internal async Task LogInAsync(EDLog log) { LogInMessage message = new LogInMessage(); message.ApiKey = ApiKey; message.Name = log.Player.Name; message.ShipType = log.Player.ShipType; await _connection.InvokeAsync("LogIn", message); }
public ActionResult LogOut() { string requestForUserInstance = Request[Consts.RequestIdForUserData]; try { LogInMessage UserObject = JsonConvert.DeserializeObject <LogInMessage>(requestForUserInstance); for (int i = 0; i <= CurrentUsersLog.Count; i++) { CurrentUsersLog.Remove(CurrentUsersLog.Find(x => x.username == UserObject.username)); } } catch { } return(Content(JsonConvert.SerializeObject(true))); }
private void ListUserTeams(LogInMessage login) { var teams = teamBuddyRepository.GetAllMyTeams(login.SignedUser.Id); Teams.AddRange(teams); }