/// <summary> /// 로그인 시도 /// </summary> /// <param name="obj">패스워드 Entry 객체</param> private async void LoginExecuteMethod(object obj) { string pw = (obj as Entry).Text; if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(pw)) { MessageService.Show(ErrorMessage.empty); return; } EncryptoService encryptoService = new EncryptoService(); pw = encryptoService.Generate(pw); string responseToken = await webService.SendGet(Urls.SIGNIN, id, pw); if (string.IsNullOrEmpty(responseToken)) { MessageService.Show(ErrorMessage.notMember); return; } propertyService.Write(Property.User.token, responseToken); propertyService.Write(Property.User.email, id); App.Current.MainPage = new HomeView(); }
/// <summary> /// 회원가입 시도 /// </summary> /// <param name="obj">패스워드 Entry 객체</param> private async void SignUpExecuteMethod(object obj) { string pw = (obj as Entry).Text; if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(pw)) { MessageService.Show(ErrorMessage.empty); return; } EncryptoService encryptoService = new EncryptoService(); pw = encryptoService.Generate(pw); Dictionary <string, string> value = new Dictionary <string, string>(); value.Add(Property.User.email, id); value.Add(Property.User.password, pw); string result = await webService.SendPost(Urls.SIGNUP, value); if (string.IsNullOrEmpty(result)) { MessageService.Show(ErrorMessage.existUser); return; } MessageService.Show(SuccessMessage.signUp); App.Current.MainPage = new LoginView(); }
public static Boolean SetupUserToForgotPasswordState(user user, SampleDBContext DBContext = null) { if (DBContext == null) { DBContext = new SampleDBContext(); } // update user reset_password_token user.reset_password_token = EncryptoService.GetSpecificLengthRandomString(64, true); user.reset_experation = DateTime.Now.AddMinutes(10); return(DBContext.SaveChanges() == 1); }
public static user Register(string email, string password, SampleDBContext DBContext = null) { if (DBContext == null) { DBContext = new SampleDBContext(); } SaltedPassword saltedPassword = EncryptoService.GenerateSaltedHash(64, password); user newUser = new user() { email = email, salt = saltedPassword.Salt, password = saltedPassword.Hash, created_at = DateTime.Now }; try { DBContext.users.Add(newUser); DBContext.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.ToString()); } return(newUser); }