/// <summary> /// Fixed: /// </summary> public static string Register(Context context) { var ss = new SiteSettings(); var passphrase = Strings.NewGuid(); var mailAddress = Forms.Data("Users_DemoMailAddress"); var tenantModel = new TenantModel() { TenantName = mailAddress }; tenantModel.Create(context: context, ss: ss); var demoModel = new DemoModel() { TenantId = tenantModel.TenantId, Passphrase = passphrase, MailAddress = mailAddress }; demoModel.Create(context: context, ss: ss); demoModel.Initialize(context: context, outgoingMailModel: new OutgoingMailModel() { Title = new Title(Displays.DemoMailTitle()), Body = Displays.DemoMailBody( Locations.DemoUri(passphrase), Parameters.Service.DemoUsagePeriod.ToString()), From = new System.Net.Mail.MailAddress(Parameters.Mail.SupportFrom), To = mailAddress, Bcc = Parameters.Mail.SupportFrom }); return(Messages.ResponseSentAcceptanceMail() .Remove("#DemoForm") .ToJson()); }
/// <summary> /// Fixed: /// </summary> public static string Register() { var passphrase = Strings.NewGuid(); var mailAddress = Forms.Data("Users_DemoMailAddress"); var tenantModel = new TenantModel() { TenantName = mailAddress }; tenantModel.Create(); var demoModel = new DemoModel() { TenantId = tenantModel.TenantId, Passphrase = passphrase, MailAddress = mailAddress }; demoModel.Create(); demoModel.Initialize(new OutgoingMailModel() { Title = new Title(Displays.DemoMailTitle()), Body = Displays.DemoMailBody(Url.Server(), passphrase), From = new System.Net.Mail.MailAddress(Parameters.Mail.SupportFrom), To = mailAddress, Bcc = Parameters.Mail.SupportFrom }); return(Messages.ResponseSentAcceptanceMail() .Remove("#DemoForm") .ToJson()); }
/// <summary> /// Fixed: /// </summary> private static void Initialize( this DemoModel demoModel, Context context, OutgoingMailModel outgoingMailModel) { var idHash = new Dictionary <string, long>(); var password = Strings.NewGuid().Sha512Cng(); System.Threading.Tasks.Task.Run(() => { demoModel.Initialize(context: context, idHash: idHash, password: password); outgoingMailModel.Send(context: context, ss: new SiteSettings()); }); }
/// <summary> /// Fixed: /// </summary> private static void Initialize( this DemoModel demoModel, OutgoingMailModel outgoingMailModel) { var idHash = new Dictionary <string, long>(); var loginId = LoginId(demoModel, "User1"); var password = Strings.NewGuid().Sha512Cng(); System.Threading.Tasks.Task.Run(() => { demoModel.Initialize(idHash, password); outgoingMailModel.Send(); }); }
/// <summary> /// Fixed: /// </summary> public static bool Login(Context context) { var demoModel = new DemoModel().Get( context: context, where : Rds.DemosWhere() .Passphrase(QueryStrings.Data("passphrase")) .CreatedTime( DateTime.Now.AddDays(Parameters.Service.DemoUsagePeriod * -1), _operator: ">=")); if (demoModel.AccessStatus == Databases.AccessStatuses.Selected) { var loginId = LoginId(demoModel, "User1"); var password = Strings.NewGuid().Sha512Cng(); if (!demoModel.Initialized) { var idHash = new Dictionary <string, long>(); demoModel.Initialize(context: context, idHash: idHash, password: password); } else { Rds.ExecuteNonQuery( context: context, statements: Rds.UpdateUsers( param: Rds.UsersParam().Password(password), where : Rds.UsersWhere().LoginId(loginId))); } new UserModel() { LoginId = loginId, Password = password }.Authenticate( context: context, returnUrl: string.Empty); SiteInfo.Reflesh(context: context, force: true); return(Sessions.LoggedIn()); } else { return(false); } }