コード例 #1
0
        public async Task <IActionResult> SetEmailAddress(int userId, [FromBody] ProfileChangeDto changesDto)
        {
            if (!this.VerifyUser(userId))
            {
                return(Unauthorized());
            }

            User user = await _repo.GetUser(userId);

            string token = await _userManager.GenerateChangeEmailTokenAsync(user, changesDto.EMail);

            await _mailer.SendConfirmationMail(user.Id, changesDto.EMail, token, true);

            return(Ok());
        }
コード例 #2
0
        public async Task <IActionResult> ChangePassword(int userId, [FromBody] ProfileChangeDto changesDto)
        {
            if (!this.VerifyUser(userId))
            {
                return(Unauthorized());
            }

            bool changed = await _repo.ChangePassword(userId, changesDto.CurrentPassword, changesDto.Password);

            if (changed)
            {
                return(NoContent());
            }
            throw new Exception("Error updating E-Mail address");
        }
コード例 #3
0
        public async Task <IActionResult> SetDisplayName(int userId, [FromBody] ProfileChangeDto changesDto)
        {
            if (!this.VerifyUser(userId))
            {
                return(Unauthorized());
            }

            User user = await _repo.GetUser(userId);

            user.DisplayName = changesDto.DisplayName;

            if (await _repo.SaveAll())
            {
                return(NoContent());
            }

            throw new Exception("Error updating display name");
        }