示例#1
0
        public void UpdateProfile(AccountProfileModel model)
        {
            Guid userId = this.GetCurrentUserId();
            var  data   = this._repoUser.Find(userId);

            if (!string.IsNullOrEmpty(model.password))
            {
                if (string.IsNullOrEmpty(model.newPassword))
                {
                    throw new Exception("Please provide new password.");
                }

                CryptLib _crypt = new CryptLib();

                string decryptedPassword = _crypt.decrypt(data.password, data.hashKey, data.vector);
                if (decryptedPassword != model.password)
                {
                    throw new Exception("Invalid Password.");
                }

                string hashShaKey = GetSettingValue("HRIS_HASHSHA_KEY");
                string key        = CryptLib.getHashSha256(hashShaKey, 31); //32 bytes = 256 bits
                string iv         = CryptLib.GenerateRandomIV(16);
                string encrypted  = _crypt.encrypt(model.newPassword, key, iv);
                data.password = encrypted;
                data.hashKey  = key;
                data.vector   = iv;
            }

            data.email       = model.email;
            data.updatedBy   = userId;
            data.updatedDate = DateTime.Now;
            this._repoUser.Update(data);
            this._unitOfWork.Save();
        }
        public ActionResult Account(AccountProfileModel model, int page = 1)
        {
            bool isAuthorized = Session["Authorized"] != null ? (bool)Session["Authorized"] : false;

            if (isAuthorized)
            {
                model.Name = (string)Session["UserName"];
                var result = accountService.GetUserData(model.Name);

                model.Email = result.Email;
                if (result.ComicList != null && result.ComicList.Count() > 0)
                {
                    model.ComicList = result.ComicList.ToPagedList(page, 4);
                }

                model.IsAdmin = result.IsAdmin;

                return(Request.IsAjaxRequest()
                ? (ActionResult)PartialView("_UserComicList", model.ComicList)
                : View(model));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
示例#3
0
        public ActionResult UpdateAccountProfile(AccountProfileModel model)
        {
            if (model.SetPassword && !ModelState.IsValid)
            {
                return(this.CurrentUmbracoPage());
            }

            if (!(ModelState.IsValidField("firstName") && ModelState.IsValidField("lastName")))
            {
                return(this.CurrentUmbracoPage());
            }

            var customer = (ICustomer)CurrentCustomer;

            customer.FirstName = model.FirstName;
            customer.LastName  = model.LastName;

            MerchelloServices.CustomerService.Save(customer);

            if (model.SetPassword)
            {
                var member = Membership.GetUser();
                if (member == null)
                {
                    var nullReference = new NullReferenceException("Current member was null in change password operation");
                    LogHelper.Error <BazaarAccountController>("Attempt to change password failed", nullReference);
                    throw nullReference;
                }

                member.ChangePassword(model.OldPassword, model.Password);
            }

            return(this.SuccessfulRedirect(model.AccountPageId));
        }
示例#4
0
        public ActionResult MyProfile()
        {
            var model = new AccountProfileModel
            {
                User = _userService.GetByUserName(User.Identity.Name),
            };

            return(View(model));
        }
示例#5
0
        public User UpdateAuth0User(AccountProfileModel customer)
        {
            _managementClient = CreateManagementApiClientIfNotExists();
            var request = new UserUpdateRequest();

            request.UserMetadata = new { customer.FirstName, customer.LastName, customer.Picture, customer.SubscribedToNewsletter, customer.Phone };

            var response = _managementClient.Users.UpdateAsync(customer.UserId, request).GetAwaiter().GetResult();

            return(response);
        }
        public ActionResult Profile(AccountProfileModel model)
        {
            //long userId = Convert.ToInt64(Session["userId"]);
            var userData = _readOnlyRepository.First <Account>(x => x.EMail == User.Identity.Name);

            userData.Name     = model.Name;
            userData.LastName = model.LastName;
            _writeOnlyRepository.Update(userData);

            return(RedirectToAction("ListAllContent", "Disk"));
        }
示例#7
0
        public virtual MvcMailMessage RegistrationConfirmMail(AccountProfileModel customer)
        {
            ViewData.Model = customer;
            string subject = _language.ToUpper() == "EN" ? "Confirm your registration" : "Bevestig je aanmelding";

            return(Populate(x =>
            {
                x.Subject = subject;
                x.ViewName = $"~/Views/Mailing/RegistrationConfirmMail.{_language.ToUpper()}.cshtml";
                x.To.Add(customer.EmailAddress);
            }));
        }
示例#8
0
        public ActionResult Register(Models.RegisterModel model)
        {
            if (!ReCaptcha.Validate(DataUtils.GetConfig("reCaptcha:SecretKey")))
            {
                ModelState.AddModelError("", "Captcha cannot be empty");
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var users = _auth0Helper.SearchAuth0UserByEmail(model.EmailAddress);
                    if (!users.Any())
                    {
                        var newUser = new SignupUserRequest();
                        newUser.ClientId     = Auth0Helper.Auth0ClientId;
                        newUser.Connection   = Auth0Helper.Connection;
                        newUser.Email        = model.EmailAddress;
                        newUser.Password     = model.Password;
                        newUser.UserMetadata = new { model.FirstName, model.LastName, model.PhoneNumber };

                        SignupUserResponse response = _client.SignupUserAsync(newUser).Result;

                        var customer = new AccountProfileModel(model.Content)
                        {
                            UserId       = $"auth0|{response.Id}",
                            EmailAddress = model.EmailAddress,
                            FirstName    = model.FirstName,
                            LastName     = model.LastName
                        };

                        MailController.Instance(Request, model.Content, CurrentUser.LanguageCode).RegistrationConfirmMail(customer).Send();
                        return(Redirect($"/{CurrentUser.LanguageCode}/account/confirm-your-email-address/"));
                    }
                    else
                    {
                        var unverifiedUser = users.FirstOrDefault(u => u.UserId.StartsWith("auth0") && u.EmailVerified == false);
                        if (unverifiedUser != null)
                        {
                            return(Redirect($"/{CurrentUser.LanguageCode}/account/resend-email-verification/?u={unverifiedUser.UserId}"));
                        }
                        ModelState.AddModelError("", "E-mail adress already exists");
                    }
                }
                catch (Exception e)
                {
                    HandleAuth0Exception(e);
                }
            }
            return(CurrentUmbracoPage());
        }
示例#9
0
        public ActionResult ResendEmailVerification(ContentModel model, string u)
        {
            var unverifiedUser = _auth0Helper.GetAuth0User(u);
            var customer       = new AccountProfileModel(model.Content)
            {
                UserId       = unverifiedUser.UserId,
                EmailAddress = unverifiedUser.Email,
                FirstName    = unverifiedUser.FirstName,
                LastName     = unverifiedUser.LastName
            };

            MailController.Instance(Request, model.Content, CurrentUser.LanguageCode).RegistrationConfirmMail(customer).Send();
            return(Redirect($"/{CurrentUser.LanguageCode}/account/confirm-your-email-address/"));
        }
示例#10
0
        public IActionResult EditProfile([FromBody] AccountProfileModel value)
        {
            if (ModelState.IsValid == false)
            {
                return(BadRequest(ModelState));
            }
            bool bOk = accountMan.UpdateProfile(AuthMan.GetAccountId(this), value);

            if (bOk)
            {
                return(Ok());
            }
            return(BadRequest());
        }
示例#11
0
        public ActionResult AccountProfile(ContentModel model)
        {
            var auth0Helper = new Auth0Helper();
            var user        = auth0Helper.GetAuth0User(CurrentUser.UserId);
            var customer    = new AccountProfileModel(model.Content)
            {
                UserId                 = user.UserId,
                EmailAddress           = user.Email,
                FirstName              = user.FirstName,
                LastName               = user.LastName,
                Phone                  = user.UserMetadata != null ? user.UserMetadata.Phone : "",
                SubscribedToNewsletter = user.UserMetadata != null?Convert.ToBoolean(user.UserMetadata.SubscribedToNewsletter) : false,
            };

            return(CurrentTemplate(customer));
        }
示例#12
0
 public ActionResult MyProfile(AccountProfileModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             this._userService.UpdateProfile(model);
             model = this._userService.GetCurrentAccountProfile();
         }
     }
     catch (Exception ex)
     {
         this.AddModelError(ex);
     }
     return(View(model));
 }
示例#13
0
        public AccountProfileModel GetProfile(string accid)
        {
            Account acc = context.Accounts.Find(accid);

            if (acc == null)
            {
                return(null);
            }
            AccountProfileModel p = new AccountProfileModel();

            p.Nickname = acc.Name;
            p.Avatar   = acc.Icon;
            p.Brief    = acc.Description;
            p.Location = acc.Location;
            return(p);
        }
示例#14
0
        public ActionResult AccountProfile(AccountProfileModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    _auth0Helper.UpdateAuth0User(model);

                    SnuffoSettings.ShowMessage(TempData, "Profile Updated", "Your profile has been updated", AlertMessageType.Success);
                }
                catch (Exception e)
                {
                    HandleAuth0Exception(e);
                }
            }
            return(CurrentUmbracoPage());
        }
示例#15
0
        public async Task <AccountProfileModel> GetProfile(string accid)
        {
            Account acc = await context.Accounts.FindAsync(accid);

            if (acc == null)
            {
                return(null);
            }
            AccountProfileModel p = new AccountProfileModel();

            p.Name           = acc.Name;
            p.Avatar         = acc.Icon;
            p.Brief          = acc.Description;
            p.Location       = acc.Location;
            p.OrganizationId = acc.OrganizationId;
            p.DepartmentId   = acc.DepartmentId;

            return(p);
        }
示例#16
0
        public bool UpdateProfile(string accid, AccountProfileModel param)
        {
            if (param == null)
            {
                return(false);
            }
            Account acc = context.Accounts.Find(accid);

            if (acc == null)
            {
                return(false);
            }
            acc.Name        = param.Nickname;
            acc.Icon        = param.Avatar;
            acc.Description = param.Brief;
            acc.Location    = param.Location;

            context.SaveChangesAsync();
            return(true);
        }
示例#17
0
        public IActionResult Profile(AccountProfileModel profile)
        {
            if (ModelState.IsValid)
            {
                string FileName   = null;
                User   LoggedUser = _context.Users.Find(_auth.User.UserId);

                if (profile.Photo != null)
                {
                    if (profile.Photo.Length > 100000)
                    {
                        ModelState.AddModelError("", "Volume must be low than 1 mb");
                        ViewBag.PhotoName = profile.Photo.FileName;
                        return(View());
                    }
                    string UploadsFolder = Path.Combine(_hosting.WebRootPath, "images", "users");
                    FileName = Guid.NewGuid() + "_" + profile.Photo.FileName;
                    string FilePath = Path.Combine(UploadsFolder, FileName);
                    profile.Photo.CopyTo(new FileStream(FilePath, FileMode.Create));
                    LoggedUser.Image = FileName;
                }

                LoggedUser.FirstName = profile.FirstName;
                if (LoggedUser.IsCompany != true)
                {
                    LoggedUser.LastName = profile.LastName;
                }
                LoggedUser.Country  = profile.Country;
                LoggedUser.City     = profile.City;
                LoggedUser.Adress   = profile.Adress;
                LoggedUser.ZipCode  = profile.ZipCode;
                LoggedUser.Phone    = profile.Phone;
                LoggedUser.Facebook = profile.Facebook;
                LoggedUser.Google   = profile.Google;
                LoggedUser.AboutMe  = profile.AboutMe;

                _context.Entry(LoggedUser).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.SaveChanges();

                if (LoggedUser.IsCompany == true)
                {
                    if (LoggedUser.HasJobSubmit != true)
                    {
                        return(RedirectToAction("create", "job", new { id = LoggedUser.UserId }));
                    }
                }
                else
                {
                    if (LoggedUser.HasResume != true)
                    {
                        return(RedirectToAction("index", "resume", new { id = LoggedUser.UserId }));
                    }
                }

                return(RedirectToAction("index", "home"));
            }
            else
            {
                AccountIndexViewModel data = new AccountIndexViewModel
                {
                    Profile = profile
                };

                return(View("~/Views/Account/Profile.cshtml"));
            }
        }
示例#18
0
 public ActionResult RenderAccountProfileForm(AccountProfileModel model)
 {
     return(this.PartialView(PathHelper.GetThemePartialViewPath(model.Theme, "ProfileForm"), model));
 }