protected void Page_Load() { if (!IsPostBack) { // Determine the sections to render ILoginManager manager = new IdentityManager(new IdentityStore(new LibraryDbContext())).Logins; if (manager.HasLocalLogin(User.Identity.GetUserId())) { changePasswordHolder.Visible = true; } else { setPassword.Visible = true; changePasswordHolder.Visible = false; } CanRemoveExternalLogins = manager.GetLogins(User.Identity.GetUserId()).Count() > 1; // Render success message var message = Request.QueryString["m"]; if (message != null) { // Strip the query string from action Form.Action = ResolveUrl("~/Account/Manage"); SuccessMessage = message == "ChangePwdSuccess" ? "Your password has been changed." : message == "SetPwdSuccess" ? "Your password has been set." : message == "RemoveLoginSuccess" ? "The account was removed." : String.Empty; successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage); } } }
protected void Page_Load() { if (!IsPostBack) { // Determine the sections to render ILoginManager manager = new IdentityManager(new IdentityStore(new ApplicationDbContext())).Logins; if (manager.HasLocalLogin(User.Identity.GetUserId())) { changePasswordHolder.Visible = true; } else { setPassword.Visible = true; changePasswordHolder.Visible = false; } CanRemoveExternalLogins = manager.GetLogins(User.Identity.GetUserId()).Count() > 1; // Render success message var message = Request.QueryString["m"]; if (message != null) { // Strip the query string from action Form.Action = ResolveUrl("~/Account/Manage"); SuccessMessage = message == "ChangePwdSuccess" ? "Your password has been changed." : message == "SetPwdSuccess" ? "Your password has been set." : message == "RemoveLoginSuccess" ? "The account was removed." : String.Empty; successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage); } ApplicationDbContext context = new ApplicationDbContext(); string username = User.Identity.GetUserName(); var image = context.Users.FirstOrDefault(u => u.UserName == username).AvatarLink; string imageURL = AVATAR_PATH + image; this.ImageAvatar.ImageUrl = imageURL; } }
protected void Page_Load() { if (!IsPostBack) { // Determine the sections to render ILoginManager manager = new IdentityManager(new IdentityStore(new ForumEmeraldContext())).Logins; if (manager.HasLocalLogin(User.Identity.GetUserId())) { changePasswordHolder.Visible = true; } else { setPassword.Visible = true; changePasswordHolder.Visible = false; } CanRemoveExternalLogins = manager.GetLogins(User.Identity.GetUserId()).Count() > 1; // Render success message var message = Request.QueryString["m"]; if (message != null) { // Strip the query string from action Form.Action = ResolveUrl("~/Account/Manage"); SuccessMessage = message == "ChangePwdSuccess" ? "Your password has been changed." : message == "SetPwdSuccess" ? "Your password has been set." : message == "RemoveLoginSuccess" ? "The account was removed." : String.Empty; successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage); } var context = new ForumEmeraldContext(); using (context) { var username = this.User.Identity.GetUserName(); var user = context.Users.FirstOrDefault(x => x.UserName == username); this.ImageProfilePicture.ImageUrl = user.PhotoPath; this.ImageProfilePicture.AlternateText = user.UserName; this.LabelCurrentEmail.Text = this.Server.HtmlEncode(user.Email); this.CurrentUser.InnerText = this.Server.HtmlEncode(user.UserName); } } }
protected void Page_Load() { if (!IsPostBack) { // Determine the sections to render ILoginManager manager = new IdentityManager(new IdentityStore()).Logins; if (manager.HasLocalLogin(User.Identity.GetUserId())) { changePasswordHolder.Visible = true; } else { setPassword.Visible = true; changePasswordHolder.Visible = false; } CanRemoveExternalLogins = manager.GetLogins(User.Identity.GetUserId()).Count() > 1; // Render success message var message = Request.QueryString["m"]; if (message != null) { // Strip the query string from action Form.Action = ResolveUrl("~/Account/Manage"); SuccessMessage = message == "ChangePwdSuccess" ? "Your password has been changed." : message == "SetPwdSuccess" ? "Your password has been set." : message == "RemoveLoginSuccess" ? "The account was removed." : String.Empty; successMessage.Visible = !String.IsNullOrEmpty(SuccessMessage); } } var username = Context.User.Identity.Name; var context = new AcademyDbContext(); var user = context.Users.FirstOrDefault(u => u.UserName == username); if (user != null) { var avatarPath = user.AvatarPath; var avatarImage = this.PlaceHolderChangeAvatar.FindControl("ImageUserAvatar") as Image; avatarImage.ImageUrl = avatarPath; } }