Example #1
0
        private async Task SignInAsync(Template.Data.ApplicationUser user, bool isPersistent, IAuthenticationManager authenticationManager)
        {
            authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
            var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);

            authenticationManager.SignIn(new AuthenticationProperties()
            {
                IsPersistent = isPersistent
            }, identity);
        }
Example #2
0
        public void AddClinic(ClinicView objClinicView, IAuthenticationManager authenticationManager)
        {
            using (var clinicrepo = new ClinicRepository())
            {
                var newuser = new Template.Data.ApplicationUser()
                {
                    Id            = objClinicView.User.UserName,
                    UserName      = objClinicView.User.UserName,
                    Email         = objClinicView.User.UserName,
                    PasswordHash  = UserManager.PasswordHasher.HashPassword(objClinicView.User.Password),
                    SecurityStamp = Guid.NewGuid().ToString()
                };

                var clinic = new Clinic {
                    ClinicId = objClinicView.ClinicId, ClinicName = objClinicView.ClinicName, User = newuser
                };
                clinicrepo.Insert(clinic);
            }
        }
        public async Task <bool> RegisterUser(RegisterModel objRegisterModel, IAuthenticationManager authenticationManager)
        {
            var newuser = new Template.Data.ApplicationUser()
            {
                Id           = objRegisterModel.UserName,
                UserName     = objRegisterModel.UserName,
                Email        = objRegisterModel.UserName,
                PasswordHash = UserManager.PasswordHasher.HashPassword(objRegisterModel.Password)
            };

            var result = await UserManager.CreateAsync(
                newuser, objRegisterModel.Password);

            if (result.Succeeded)
            {
                await SignInAsync(newuser, false, authenticationManager);

                return(true);
            }
            return(false);
        }