// GET: Activation public ActionResult Activate(string email, string validationkey) { Responses.BaseResponse response = new Responses.BaseResponse((int)CommonContant.LANGUAGEID.TR); try { using (Data.SimpleData db = new Data.SimpleData()) { var User = db.Users.FirstOrDefault(t => t.Email == email); string userkey = null; if (User != null) { userkey = Security.sha512encrypt(User.ValidationKey); } if (userkey == validationkey) { User.ActiveStatus = (int)CommonContant.ActiveStatus.activeuser; User.ValidationKey = RandomSfr.Generate(10); db.Entry(User).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } else { response.SetErrror(CommonContant.ERROR_CODE.SECURTYERROR); return(View(response)); } } } catch (Exception ex) { response.SetErrror(CommonContant.ERROR_CODE.SYSTEM_ERROR); return(View(response)); } return(View(response)); }
public async Task <ActionResult> Register(Data.User user) { user.EmailConfirm = false; user.ActiveStatus = (int)CommonContant.ActiveStatus.pasif; user.Password = SimpleLogin.Common.Security.sha512encrypt(user.Password).Substring(0, 70); user.ValidationKey = RandomSfr.Generate(10); Data.SimpleData db = new Data.SimpleData(); db.Entry(user).State = System.Data.Entity.EntityState.Added; try { int result = await db.SaveChangesAsync(); //db ye kayıt edildi if (result == 1) { string link = "http://localhost:58522/Activation/Activate/" + user.Email + "/" + Security.sha512encrypt(user.ValidationKey); string emailFromTemplate = HelperFunction.RenderViewToString(this.ControllerContext, "~/Views/MailTemplates/UserActivation.cshtml", link); //todo: metod async yapılacak Common.MailOperations.sendMailFORapp("WissenApp Kayıt", emailFromTemplate, user.Email); return(RedirectToAction("ActivationInfo")); } } catch (Exception ex) { throw; } return(View()); }