public busUser RegisterOrLoginSocialUser(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/registerOrLoginSocialUser"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
public busUser ForgotPassword(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/forgotPassword"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
public busUser Enroll(busUser abusUser) { busUser lbusUser = null; abusUser.idoUser.networkId = 1; if (abusUser.idoUser.networkValue == null) { abusUser.idoUser.networkValue = busConstant.ApplicationNetwork; } abusUser.idoUser.networkUserId = abusUser.idoUser.emailAddress; abusUser.idoUser.displayName = abusUser.idoUser.firstName + " " + abusUser.idoUser.lastName; abusUser.idoUser.birthDate = ""; abusUser.idoUser.iintUserId = 1; UserService userService = new UserService(); if (abusUser.idoUser.networkValue == busConstant.ApplicationNetwork) { lbusUser = userService.EnrollUser(abusUser); } else { lbusUser = userService.RegisterOrLoginSocialUser(abusUser); } return(lbusUser); }
public busUser GetUserByEmailAndOTP(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/getUserByEmailAndOTP"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
public busUser EnrollUser(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/enrollUser"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
public busUser UpdateUserProfile(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/user/updateUserProfile"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
public busUser ValidateUser(busUser abusUser) { ibusRestService = new busRestService(); modularUrl = modularUrl + "/validateUser"; return(ibusRestService.Post <busUser>(modularUrl, abusUser)); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); ViewModel.ErrorDisplay = ErrorDisplay; ViewModel.AppUserState = AppUserState; busUser = CodePasteFactory.GetUser(); }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); this.ViewModel.ErrorDisplay = this.ErrorDisplay; this.ViewModel.AppUserState = this.AppUserState; this.busUser = CodePasteFactory.GetUser(); }
protected override void Dispose(bool disposing) { if (busUser != null) { busUser.Dispose(); busUser = null; } base.Dispose(disposing); }
public BaseController() { var userFromAuthCookie = System.Threading.Thread.CurrentPrincipal; if (userFromAuthCookie != null && userFromAuthCookie.Identity.IsAuthenticated) // && !String.IsNullOrEmpty(userFromAuthCookie.Identity.Name)) { busUser userBO = AceFactory.GetUser(); string userNameFromAuthCookie = userFromAuthCookie.Identity.Name; _UserId = userBO.GetUserIdByUsername(userNameFromAuthCookie); } }
protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); busUser = CodePasteFactory.GetUser(); ViewModel.busUser = busUser; ViewModel.ErrorDisplay = ErrorDisplay; ViewModel.AppUserState = AppUserState; ViewData["UserState"] = AppUserState; }
/// <summary> /// Validates a user and returns the user entity as a result or fails /// and throws a SOAP exception to fail the request. /// </summary> /// <param name="email"></param> /// <param name="password"></param> /// <returns></returns> private User ValidateUser(string email, string password) { busUser busUser = CodePasteFactory.GetUser(); User user = busUser.ValidateUserAndLoad(email, password); if (user == null) { this.ThrowException(busUser.ErrorMessage); } return(user); }
public bool RemoveUser(string userId) { if (!AppUserState.IsAdmin) { throw new UnauthorizedAccessException("Unauthorized Access: You have to be signed in as an administrator in delete snippets."); } using (var userBus = new busUser()) { return(userBus.Delete(userId)); } }
public ActionResult UpdatePasswords() { var userBus = new busUser(); foreach (var user in userBus.Context.Users) { userBus.Load(user.Id); userBus.Save(user); } ViewModel.ErrorDisplay.ShowMessage("User accounts have been updated."); return(View("Index", ViewModel)); }
public async Task <ActionResult> ExternalLoginCallback(string returnUrl) { if (string.IsNullOrEmpty(returnUrl)) { returnUrl = "~/"; } var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return(RedirectToAction("LogOn")); } // AUTHENTICATED! var providerKey = loginInfo.Login.ProviderKey; // Aplication specific code goes here. var userBus = new busUser(); var user = userBus.ValidateUserWithExternalLogin(providerKey); if (user == null) { return(RedirectToAction("LogOn", new { message = "Unable to log in with " + loginInfo.Login.LoginProvider + ". " + userBus.ErrorMessage })); } // store on AppUser AppUserState appUserState = new AppUserState(); appUserState.FromUser(user); // write the authentication cookie IdentitySignin(appUserState, providerKey, isPersistent: true); return(Redirect(returnUrl)); }
public async Task <ActionResult> ExternalLinkLoginCallback() { // Handle external Login Callback var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, AppUserState.UserId); if (loginInfo == null) { IdentitySignout(); // to be safe we log out return(RedirectToAction("Register", new { message = "Unable to authenticate with external login." })); } // Authenticated! string providerKey = loginInfo.Login.ProviderKey; string providerName = loginInfo.Login.LoginProvider; // Now load, create or update our custom user // normalize email and username if available if (string.IsNullOrEmpty(AppUserState.Email)) { AppUserState.Email = loginInfo.Email; } if (string.IsNullOrEmpty(AppUserState.Name)) { AppUserState.Name = loginInfo.DefaultUserName; } var userBus = new busUser(); User user = null; if (!string.IsNullOrEmpty(AppUserState.UserId)) { user = userBus.Load(AppUserState.UserId); } if (user == null && !string.IsNullOrEmpty(providerKey)) { user = userBus.LoadUserByProviderKey(providerKey); } if (user == null && !string.IsNullOrEmpty(loginInfo.Email)) { user = userBus.LoadUserByEmail(loginInfo.Email); } if (user == null) { user = userBus.NewEntity(); userBus.SetUserForEmailValidation(user); } if (string.IsNullOrEmpty(user.Email)) { user.Email = AppUserState.Email; } if (string.IsNullOrEmpty(user.Name)) { user.Name = AppUserState.Name ?? "Unknown (" + providerName + ")"; } if (loginInfo.Login != null) { user.OpenIdClaim = loginInfo.Login.ProviderKey; user.OpenId = loginInfo.Login.LoginProvider; } else { user.OpenId = null; user.OpenIdClaim = null; } // finally save user inf bool result = userBus.Save(user); // update the actual identity cookie AppUserState.FromUser(user); IdentitySignin(AppUserState, loginInfo.Login.ProviderKey); return(RedirectToAction("Register")); }
public ActionResult New(FormCollection formValues) { ViewData["UserState"] = AppUserState; ViewData["languageList"] = this.GetLanguageList(); busCodeSnippet busSnippet = new busCodeSnippet(); CodeSnippet snippet = busSnippet.NewEntity(); if (snippet == null) { ErrorDisplay.ShowError("Couldn't load snippet"); return View(new CodeSnippet()); } UpdateModel(snippet); if (!ValidateForSpam(snippet)) { this.ErrorDisplay.ShowError("Invalid data posted back."); return View(snippet); } if (!busSnippet.Validate()) { foreach (ValidationError error in busSnippet.ValidationErrors) { this.ErrorDisplay.AddMessage(error.Message, error.ControlID); } this.ErrorDisplay.ShowError("Please correct the following:"); return View(snippet); } // Assign the user from the authenticated user if any - otherwise blank // in which case the user can't edit entries. snippet.UserId = this.AppUserState.UserId; // if (!string.IsNullOrEmpty(snippet.UserId)) { var userBus = new busUser(); var user = userBus.Load(snippet.UserId); if (user.InActive) { ErrorDisplay.HtmlEncodeMessage = false; ErrorDisplay.ShowError( @"Your email address has not been validated yet so you can't create posts for this account yet. Please click the following link and then check your email for a message to validate your email.<br><br> <a href='" + Url.Content("~/Account/ResetEmailValidation") + "' target='emailreset'>Send Validation Request Email</a>"); return View(snippet); } } // strip of leading indentation always when capturing a new snippet snippet.Code = StringUtils.NormalizeIndentation(snippet.Code); if (!busSnippet.Save()) { this.ErrorDisplay.ShowError("Couldn't save snippet: " + busSnippet.ErrorMessage); return View(snippet); } return this.RedirectToAction("Show", new { id = busSnippet.Entity.Id }); }
public async Task<ActionResult> ExternalLinkLoginCallback() { // Handle external Login Callback var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(XsrfKey, AppUserState.UserId); if (loginInfo == null) { IdentitySignout(); // to be safe we log out return RedirectToAction("Register", new {message = "Unable to authenticate with external login."}); } // Authenticated! string providerKey = loginInfo.Login.ProviderKey; string providerName = loginInfo.Login.LoginProvider; // Now load, create or update our custom user // normalize email and username if available if (string.IsNullOrEmpty(AppUserState.Email)) AppUserState.Email = loginInfo.Email; if (string.IsNullOrEmpty(AppUserState.Name)) AppUserState.Name = loginInfo.DefaultUserName; var userBus = new busUser(); User user = null; if (!string.IsNullOrEmpty(AppUserState.UserId)) user = userBus.Load(AppUserState.UserId); if (user == null && !string.IsNullOrEmpty(providerKey)) user = userBus.LoadUserByProviderKey(providerKey); if (user == null && !string.IsNullOrEmpty(loginInfo.Email)) user = userBus.LoadUserByEmail(loginInfo.Email); if (user == null) { user = userBus.NewEntity(); userBus.SetUserForEmailValidation(user); } if (string.IsNullOrEmpty(user.Email)) user.Email = AppUserState.Email; if (string.IsNullOrEmpty(user.Name)) user.Name = AppUserState.Name ?? "Unknown (" + providerName + ")"; if (loginInfo.Login != null) { user.OpenIdClaim = loginInfo.Login.ProviderKey; user.OpenId = loginInfo.Login.LoginProvider; } else { user.OpenId = null; user.OpenIdClaim = null; } // finally save user inf bool result = userBus.Save(user); // update the actual identity cookie AppUserState.FromUser(user); IdentitySignin(AppUserState, loginInfo.Login.ProviderKey); return RedirectToAction("Register"); }
public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { if (string.IsNullOrEmpty(returnUrl)) returnUrl = "~/"; var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) return RedirectToAction("LogOn"); // AUTHENTICATED! var providerKey = loginInfo.Login.ProviderKey; // Aplication specific code goes here. var userBus = new busUser(); var user = userBus.ValidateUserWithExternalLogin(providerKey); if (user == null) { return RedirectToAction("LogOn", new { message = "Unable to log in with " + loginInfo.Login.LoginProvider + ". " + userBus.ErrorMessage }); } // store on AppUser AppUserState appUserState = new AppUserState(); appUserState.FromUser(user); // write the authentication cookie IdentitySignin(appUserState, providerKey, isPersistent: true); return Redirect(returnUrl); }
public ActionResult UpdatePasswords() { var userBus = new busUser(); foreach (var user in userBus.Context.Users) { userBus.Load(user.Id); userBus.Save(user); } ViewModel.ErrorDisplay.ShowMessage("User accounts have been updated."); return View("Index",this.ViewModel); }
public ActionResult New(FormCollection formValues) { ViewData["UserState"] = AppUserState; ViewData["languageList"] = this.GetLanguageList(); busCodeSnippet busSnippet = new busCodeSnippet(); CodeSnippet snippet = busSnippet.NewEntity(); if (snippet == null) { ErrorDisplay.ShowError("Couldn't load snippet"); return(View(new CodeSnippet())); } UpdateModel(snippet); if (!ValidateForSpam(snippet)) { this.ErrorDisplay.ShowError("Invalid data posted back."); return(View(snippet)); } if (!busSnippet.Validate()) { foreach (ValidationError error in busSnippet.ValidationErrors) { this.ErrorDisplay.AddMessage(error.Message, error.ControlID); } this.ErrorDisplay.ShowError("Please correct the following:"); return(View(snippet)); } // Assign the user from the authenticated user if any - otherwise blank // in which case the user can't edit entries. snippet.UserId = this.AppUserState.UserId; // if (!string.IsNullOrEmpty(snippet.UserId)) { var userBus = new busUser(); var user = userBus.Load(snippet.UserId); if (user.InActive) { ErrorDisplay.HtmlEncodeMessage = false; ErrorDisplay.ShowError( @"Your email address has not been validated yet so you can't create posts for this account yet. Please click the following link and then check your email for a message to validate your email.<br><br> <a href='" + Url.Content("~/Account/ResetEmailValidation") + "' target='emailreset'>Send Validation Request Email</a>"); return(View(snippet)); } } // strip of leading indentation always when capturing a new snippet snippet.Code = StringUtils.NormalizeIndentation(snippet.Code); if (!busSnippet.Save()) { this.ErrorDisplay.ShowError("Couldn't save snippet: " + busSnippet.ErrorMessage); return(View(snippet)); } return(this.RedirectToAction("Show", new { id = busSnippet.Entity.Id })); }