예제 #1
0
        private async Task RegisterAccount(HttpContext context)
        {
            var actionType = context.Request.Form["actiontype"];
            var loginData  = context.Request.Form["logindata"];

            if (_loginHandler == null || actionType != _loginHandler.ActionType)
            {
                context.Response.StatusCode = 400;
                await context.Response.WriteAsync("Bad request.");

                return;
            }

            var account = await _loginHandler.GetAccount(loginData);

            if (account == null)
            {
                context.Response.StatusCode = 400;
                await context.Response.WriteAsync("Bad request.");

                return;
            }

            try
            {
                _registerService.Register(account);
            }
            catch (Exception ex)
            {
                context.Response.StatusCode = 400;
                await context.Response.WriteAsync(ex.Message + ex.StackTrace);
            }
        }