Ejemplo n.º 1
0
        public async Task <IActionResult> Login(string nameOrEmail, string password)
        {
            var user = await authManager.LoginAsync(nameOrEmail, password);

            await jweService.RenewSecurityTokensAsync(HttpContext, user);

            return(Ok());
        }
Ejemplo n.º 2
0
        public virtual async Task <IActionResult> SetMyName(string password, string name)
        {
            var user = await GetUserAsync();

            if (!await userManager.CheckPasswordAsync(user, password))
            {
                return(BadRequest(new Error("PasswordInvalid", "Wrong password")));
            }

            name = Regex.Replace(name.Trim(), " {2,}", "");

            if (!await personalManager.ValidateNameAsync(name, user.Id))
            {
                return(BadRequest(new Error("NameInvalid", "Validation error")));
            }

            await personalManager.SetMyNameAsync(user, name);

            Response.Headers.Clear();

            await jweService.RenewSecurityTokensAsync(HttpContext, user, User.SessionId);

            return(Ok());
        }