Example #1
0
        public static void Login(string username, string pass, Respone <UserEnt> respone)
        {
            try
            {
                UserEnt user = Storage.Instance.GetUser(username);
                if (user == null || Storage.MD5Hash(pass) != user.Password)
                {
                    respone.onFail("Đăng nhập thất bại");
                    return;
                }

                respone.onSuccess(user);
            } catch (Exception e)
            {
                respone.onError(e.Message);
            }
        }
Example #2
0
        public static void Register(string username, string pass, Respone <UserEnt> respone)
        {
            try
            {
                UserEnt user = new UserEnt();
                user.Username = username.Trim().ToUpper();
                user.Password = pass;

                if (!Storage.Instance.AddUser(user))
                {
                    respone.onFail("Tên đã tồn tại");
                    return;
                }

                respone.onSuccess(user);
            }
            catch (Exception e)
            {
                respone.onError(e.Message);
            }
        }