Click or drag to resize

SealSecurityDefaultTwoFAGenerationScript Field

Default implementation used when TwoFAGenerationScript is empty: sends the security code by email using the notification email device

Namespace: Seal.Model
Assembly: SealLibrary (in SealLibrary.dll) Version: 10.0.1.0+a44cd3a7f03c2bf3cdbd971a878c679e40bed08a
Syntax
C#
public const string DefaultTwoFAGenerationScript = "@{\n    SecurityUser user = Model;\n\n    //Generate the security code\n    Random rnd = new Random();\n    user.SecurityCode = rnd.Next(100000, 1000000).ToString();\n    user.SecurityCodeGeneration = DateTime.Now;\n\n    var message = user.Security.Repository.TranslateReport("Please find your authentication code");\n\n    var from = ""; //Default of the device will be used\n    var to = user.Login?.Email; //Destination email: could be got from database, LDAP, etc.\n    if (string.IsNullOrEmpty(to)) {\n        throw new Exception($"No Email Address for the user {user.WebUserName}.");\n    }\n\n    var subject = "Seal Report";\n    var body = $"{message}: <br><b>{user.SecurityCode}</b>";\n    var isHtml = true;\n\n    if (!user.Security.Repository.SendNotificationEmail(from, to, subject, isHtml, body)) {\n        throw new Exception("Unable to send email. Check that an Email Device is defined for notification. Restart the 'Server Manager' after changing the configuration.");\n    }\n\n    //Message displayed in the login page\n    user.SecurityCodeMessage = user.Security.Repository.TranslateReport("A security code has been sent by Email at") + $": {Helper.MaskEmail(to)}";\n}\n"

Field Value

String
See Also