示例#1
0
        public async Task <IActionResult> Profile(ProfileModel model, string returnUrl = null)
        {
            var authResult = await HttpContext.AuthenticateAsync("Temporary");

            //if user not temporarily signedin, redirect to signin page
            if (!authResult.Succeeded)
            {
                return(RedirectToAction("SignIn"));
            }
            //if model state is valie
            if (ModelState.IsValid)
            {
                //code bit optimistic. Its not checking whether user with the same details already exist or not etc...
                var user = await _registerUserService.AddUser(authResult.Principal.FindFirst(ClaimTypes.NameIdentifier).Value, model.DisplayName, model.Email);

                return(await SignInUser(user, returnUrl));
            }

            //if model state not valid then send user to model
            return(View(model));
        }