private string InsertLink(string body, string email, TokenService tokens) { if (body.IndexOf("!!link!!") != -1) { var token = tokens.Login(email); var combine = string.Format("{0}!{1}", email, token); var link = string.Format(@"<a href=""{0}/#/?token={1}"">your secret key</a>", this.Request.Url.SiteBase, combine); return body.Replace("!!link!!", link) + "<br><br> Sent on behalf of " + email; } return body; }
public LoginModule() : base("/api/login") { var db = new CouchDB.CouchDBService(); var tokenService = new TokenService(db); Post["/"] = ctx => { string username; var dto = this.Bind<LoginRequestDto>(); username = dto.Username; var validationResponse = ValidateUsername(username); if (validationResponse != null) return validationResponse; var token = tokenService.Login(username); var combine = string.Format("{0}!{1}", username, token); MailgunService.SendMail(username, "The unicorn says hi!", string.Format(File.ReadAllText(Path.Combine(AssemblyDirectory, "Mailing\\LoginMailResponse.txt")), this.Request.Url.SiteBase, combine)); return HttpStatusCode.OK; }; }