Ejemplo n.º 1
0
        /// <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();
        }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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);
        }