예제 #1
0
        public IActionResult Add([FromBody] UserAddForm u)
        {
            try
            {
                if (u is null)
                {
                    throw new ArgumentNullException("User Object Empty (ADD)");
                }

                string testpasswd = _cryptoService.Decrypter(Convert.FromBase64String(u.Passwd));
                // User uo = new User() {Email = u.Email, NatRegNbr = u.NatRegNbr, FirstName = u.FirstName, LastName = u.LastName, Passwd = (Base64.Base64Decode(u.Passwd)};
                User uo = new User()
                {
                    Email = u.Email, NatRegNbr = u.NatRegNbr, FirstName = u.FirstName, LastName = u.LastName, Passwd = _cryptoService.Decrypter(Convert.FromBase64String(u.Passwd))
                };



                uo = _clientService.Add(uo);
                return(ApiControllerHelper.SendOk(this, new ApiResult <User>(HttpStatusCode.OK, null, uo), true));
            }
            catch (Exception ex)
            {
                return(ApiControllerHelper.SendError(this, ex));
            }
        }
예제 #2
0
        public IActionResult PutPassword(int id, [FromBody] Password pwd)
        {
            pwd.Passwd    = _cryptoService.Decrypter(Convert.FromBase64String(pwd.Passwd));
            pwd.NewPasswd = _cryptoService.Decrypter(Convert.FromBase64String(pwd.NewPasswd));

            if (_passwordRepository.UpdatePasswd(id, pwd))
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
예제 #3
0
        public IActionResult Register(RegisterForm registerForm)
        {
            if (!(registerForm is null) && ModelState.IsValid)
            {
                //_logger.LogInformation($"{registerForm.Passwd}");
                registerForm.Passwd = _cryptoService.Decrypter(Convert.FromBase64String(registerForm.Passwd));
                //_logger.LogInformation($"{registerForm.Passwd}");

                try
                {
                    _authRepository.Register(registerForm);
                    return(Ok());
                }
                catch (Exception ex)
                {
                    return(BadRequest());
                }
            }

            return((!(registerForm is null)) ? BadRequest(ModelState) : BadRequest("There is no Data !"));
        }
예제 #4
0
        public void Register(RegisterForm registerForm)
        {
            string password = _cryptoService.Decrypter(Convert.FromBase64String(registerForm.Passwd));

            //insert into database
        }