예제 #1
0
        public async Task<IdentityResult> RegisterUser(PlayerModel userModel)
        {
            Player user = new Player
            {
                 UserName = userModel.UserName,
                 FirstName = userModel.FirstName,
                 LastName = userModel.LastName,
                 ContactNumber = userModel.ContactNumber,
                 Address1 = userModel.Address1,
                 Address2 = userModel.Address2,
                 Location = userModel.Location,
                 BirthDate = userModel.BirthDate,
                 Gender = userModel.Gender,
                 Email = userModel.Email
                 
            };
         
            IdentityUser identityUser = new IdentityUser
            {
                UserName = userModel.UserName
            };
            var result = await _userManager.CreateAsync(user,userModel.Password);

            return result;
        }
예제 #2
0
        //private string userName = "";
        //private string passWord = "";
        public Email(string header, string message, PlayerModel account)
        {
            this.account = account;

            this.EMailFrom = Convert.ToString(EmailServiceCred.Username);
            this.EmailTo = this.account.Email;
            this.Header = header;
            this.Message = message;
        }
예제 #3
0
        public IHttpActionResult post(RecoverDto dto)
        {
            // recovery procedures here
            if(dto == null) {
                //throw new NullDtoException();
                return InternalServerError();
            }

            AuthRepository repo = new AuthRepository();

            try {
                int confirmationNumber = new RecoveryCode().generateCode();
                var data = repo.FindUser(dto.userEmail);

                if(data == null) {
                    return InternalServerError();
                }

                PlayerModel account = new PlayerModel()
                {
                    FirstName = data.FirstName,
                    LastName = data.LastName,
                    Email = data.Email
                };

                String Message = new EmailMessage(account).ParseRecover(confirmationNumber);
                String Header = MessageTemplate.MessageTitle;

                Email mail = new Email(Header, Message, account);
                mail.SendEmail();

                return Ok(confirmationNumber);
            } catch(Exception) {
                return InternalServerError();
            }
        }
예제 #4
0
        public async Task<IHttpActionResult> Register(RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var user = new Player() { 
                UserName = model.UserName,
                Email = model.Email,
                Address1 = model.Address1,
                Address2 = model.Address2,
                BirthDate = model.BirthDate,
                FirstName = model.FirstName,
                LastName = model.LastName,
                Location = model.Location,
                Gender = model.Gender,
                ContactNumber = model.ContactNumber
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

           
            if (!result.Succeeded)
            {
                return GetErrorResult(result);
            }

            PlayerModel account = new PlayerModel() { 
                UserName = user.UserName,
                Email = user.Email,
                FirstName = user.FirstName,
                LastName = user.LastName
            };

            var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
            var urlEncode = HttpUtility.UrlEncode(code);
            var callBackUrl = "/register/confirmation/" + user.Id + "/token?code=" + urlEncode; 
            await UserManager.SendEmailAsync(user.Id, "Confirm your Account !", "Please confirm your account by clicking this link: <a href=\""
                                               + callBackUrl + "\">link</a>");

            String message = new EmailMessage(account).ParseNotify();

           

            string url = "Please confirm your account by clicking this link: <a href=\"" +
                                               "http://"+ HttpContext.Current.Request.Url.Authority + callBackUrl + "\">link</a>";
            Email mail = new Email(MessageTemplate.MessageTitle, url, account);

            mail.SendEmail();

            return Ok();
        }
예제 #5
0
        public IHttpActionResult post(CombinationDto dto)
        {
            if(dto == null) {
                return InternalServerError();
            }

            try {
                AuthRepository repo = new AuthRepository();
                var data = repo.FindUserByUserName(dto.UserName);

                if (data == null)
                {
                     data = repo.FindUser(dto.UserName);
                     dto.UserName = data.UserName;
                    if (dto.UserName == null)
                    {
                         return InternalServerError();
                    }
                }

                PlayerModel account = new PlayerModel()
                {
                    FirstName = data.FirstName,
                    LastName = data.LastName,
                    Email = data.Email
                };

                String Message = new EmailMessage(account).ParseCombination(dto.Combination);
                String Header = MessageTemplate.MessageTitle;

                Email mail = new Email(Header, Message, account);
                mail.SendEmail();

                return Ok();
            }
            catch (Exception) {
                return InternalServerError();
            }
        }