public ActionResult Invite() { IncludeMenu("invite"); // Create the URL to sign-up string url = "https://krypto.frl/signup/" + InviteTokenCreator.Create(); return(View(new InviteViewModel(url))); }
public ActionResult SignUp(string token) { // Redirect to the "/" url when the user is already signed-in if (Request.IsAuthenticated) { return(RedirectToAction("Index", "Account")); } // Validate the token if (!string.IsNullOrWhiteSpace(token) && token == InviteTokenCreator.Create()) { return(View(new SignUpViewModel() { Token = token })); } return(View("TokenExpired")); }
public ActionResult SignUp(SignUpModel model) { // Validate the token if (!string.IsNullOrWhiteSpace(model.Token) && model.Token == InviteTokenCreator.Create()) { // Check for "admin" in the username if (model.Username.ToLower().Contains("admin")) { return(CreateValidationError("Username", "Invalid username")); } // Check if the username and email exists if (AccountsManager.UsernameExists(model.Username)) { return(CreateValidationError("Username", "The username does already exist.")); } if (AccountsManager.EmailExists(model.Email)) { return(CreateValidationError("Email", "The email address does already exist.")); } // Create the account bool ok = AccountsManager.CreateAccount(model.Username.Trim().ToLower(), model.Email.Trim().ToLower(), model.Password); if (!ok) { return(CreateValidationError("Failed to create the user")); } // Set the authentication cookie FormsAuthentication.SetAuthCookie(model.Username, true); // OK return(JsonOK()); } else { // Invalid token, show error on client return(CreateValidationError("Invalid token")); } }
public ActionResult InviteQrImage() { // Create the URL to sign-up string url = "https://krypto.frl/signup/" + InviteTokenCreator.Create(); // Create the writer for the qr code BarcodeWriter writer = new BarcodeWriter(); writer.Options.Height = 300; writer.Options.Width = 300; writer.Options.Hints.Add(EncodeHintType.MARGIN, 1); writer.Format = BarcodeFormat.QR_CODE; // Render the QR code image Bitmap qrCodeBitmap = writer.Write(url); // Convert the QR code bitmap to raw bytes ImageConverter converter = new ImageConverter(); byte[] data = (byte[])converter.ConvertTo(qrCodeBitmap, typeof(byte[])); // Return the raw bytes as the request result return(File(data, "image/bmp")); }