public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UserManager.GetUserByEmailAsync(model.Email, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); if (user.IsBlocked) { SignOutProgrammaticallyNonRedirect(); return(AppVar.GetAuthenticationError("You don't have the permission.", "Sorry you don't have the permission to authenticate right now. Your account is blocked")); } if (!user.IsRegistrationComplete) { return(RedirectToActionPermanent("Verify")); } return(RedirectToLocal(returnUrl)); } ModelState.AddModelError("", "Invalid username or password."); } // If we got this far, something failed, redisplay form return(View(model)); }
public ActionResult Review(long id) { if (SessionNames.IsValidationExceed("Review-Report")) { return(View("Later")); } if (RoleManager.IsInRole(RoleNames.Rookie) == false) { // at least has a role. // since lowest priority role, it will be added while registering a user. return(AppVar.GetAuthenticationError("Unauthorized", "")); } Review review; App app; var isReportedAlready = IsReviewAlreadyReported(id, out review, out app); if (isReportedAlready == false && review != null) { ViewBag.app = app; ViewBag.review = review; ViewBag.id = id; return(View()); } if (isReportedAlready && review != null) { return(View("AlreadyReported")); } return(View("_404")); }
/// <summary> /// </summary> /// <param name="id">AppId</param> /// <returns></returns> public ActionResult App(long id) { if (SessionNames.IsValidationExceed("App-Report")) { return(View("Later")); } if (RoleManager.IsInRole(RoleNames.Rookie) == false) { return(AppVar.GetAuthenticationError("Unauthorized", "")); } // if the app is already reported. App app; var isAlreadyReported = IsAppAlreadyReported(id, out app); if (app != null) { if (isAlreadyReported) { ViewBag.isAppReport = true; // if the app is already reported return(View("AlreadyReported")); } ViewBag.id = id; ViewBag.app = app; return(View()); } return(View("_404")); }
public ActionResult Register() { if (UserManager.IsAuthenticated()) { return(AppVar.GetAuthenticationError("You are already authenticated.", "")); } return(View()); }
public ActionResult Register() { if (UserManager.IsAuthenticated()) { return(AppVar.GetAuthenticationError("Authentication Failed", "")); } return(View()); }
public async Task <ActionResult> Review(Feedback feedback, long appOrReviewId, bool hasAppId) { if (SessionNames.IsValidationExceed("Review-Report")) { return(View("Later")); } if (RoleManager.IsInRole(RoleNames.Rookie) == false) { // at least has a role. // since lowest priority role, it will be added while registering a user. return(AppVar.GetAuthenticationError("Unauthorized", "")); } Review review; App app; var isReportedAlready = IsReviewAlreadyReported(appOrReviewId, out review, out app); if (isReportedAlready == false && review != null) { // review is not reported before by this user. if (!ModelState.IsValid) { // non valid message. ViewBag.errorMessage = MessageConstants.JunkMessageResult; ViewBag.id = appOrReviewId; ViewBag.review = review; ViewBag.app = app; return(View(feedback)); } // now post the report. db2.Feedbacks.Add(feedback); // add the relationship and category. AttachNewRelationship(feedback, appOrReviewId, false); if (db2.SaveChanges() > -1) { // successfully saved. // async send an email to the admin. RemoveSessionCache(appOrReviewId, false); AppVar.Mailer.NotifyAdmin("A user has reported a review.", "Hi , <br>Please login and check at the admin panel , a review has been reported."); return(View("Done")); } return(View()); } return(View("AlreadyReported")); }
public async Task <ActionResult> Register(RegisterViewModel model) { if (UserManager.IsAuthenticated()) { return(AppVar.GetAuthenticationError("You are already authenticated.", "")); } if (ModelState.IsValid) { var errors = new ErrorCollector(); //External Validation. var validator = new DevUserValidator(model, errors, db); var validOtherConditions = validator.ValidateEveryValidations(); if (validOtherConditions) { model.UserName = model.UserName.Trim(); model.FirstName = model.FirstName.Trim(); model.LastName = model.LastName.Trim(); var user = UserManager.GetUserFromViewModel(model); // get user from view model. var result = await Manager.CreateAsync(user, model.Password); if (result.Succeeded) { if (AppVar.Setting.IsConfirmMailRequired && AppVar.Setting.IsFirstUserFound) { #region For every regular user. // First user already found. // mail needs to be confirmed and first user found. #region Send an email to the user about mail confirmation SendConfirmationEmail(user); #endregion #region Redirect to verify since registration //SignOutProgrammaticallyNonRedirect(); return(RedirectToActionPermanent("Verify")); #endregion #endregion } else if (!AppVar.Setting.IsFirstUserFound) { #region For first user / first admin user. // first user not found or email doesn't need to be checked. // first haven't found // This is for first user. #region Send an email to the user about mail confirmation SendConfirmationEmail(user); #endregion #endregion } CallCompleteRegistration(user.UserID, "Rookie"); // only will be called for first user. return(RedirectToActionPermanent("Verify")); } AddErrors(result); } } return(View("Register", model)); }