Example #1
0
        public object Login(LoginData data)
        {
            if (!OneTimeKeyCenter.Use(data.temp_key))
            {
                return new { code = ResultCode.InvalidTempKey }
            }
            ;

            bool?result = UserStore.Login(data.user_name, data.temp_key, data.pwd_hash);

            if (result == null)
            {
                return new { code = ResultCode.UserDoesNotExist }
            }
            ;
            else if (result == false)
            {
                return new { code = ResultCode.WrongPassword }
            }
            ;

            string session_key = UserCenter.Create(data.user_name);

            return(new
            {
                code = ResultCode.Success,
                session_key = session_key
            });
        }
Example #2
0
        public object GetTempKey()
        {
            string key = OneTimeKeyCenter.Create();

            return(new
            {
                code = ResultCode.Success,
                temp_key = key
            });
        }