Small changes cleanup for release
This commit is contained in:
parent
a33c78ffe9
commit
40535cf0f1
|
@ -466,12 +466,12 @@ public class Controller : ControllerBase
|
|||
if (user is null)
|
||||
return Unauthorized();
|
||||
|
||||
//todo dont hardcode url
|
||||
return Db.DeleteUserPassword(user)
|
||||
? RedirectToRoute("https://monitor.innov.energy")
|
||||
: Unauthorized();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ public static class SessionMethods
|
|||
&& user.HasAccessToParentOf(installation)
|
||||
&& Db.Create(installation) // TODO: these two in a transaction
|
||||
&& installation.SetOrderNumbers()
|
||||
&& Db.Create(new InstallationAccess { UserId = user.Id, InstallationId = installation.Id });
|
||||
//&& await installation.CreateBucket()
|
||||
//&& await installation.RenewS3Credentials(); // generation of access _after_ generation of
|
||||
&& Db.Create(new InstallationAccess { UserId = user.Id, InstallationId = installation.Id })
|
||||
&& await installation.CreateBucket()
|
||||
&& await installation.RenewS3Credentials(); // generation of access _after_ generation of
|
||||
// bucket to prevent "zombie" access-rights.
|
||||
// This might fuck us over if the creation of access rights fails,
|
||||
// as bucket-names are unique and bound to the installation id... -K
|
||||
|
@ -144,8 +144,8 @@ public static class SessionMethods
|
|||
&& installation is not null
|
||||
&& user.HasWriteAccess
|
||||
&& user.HasAccessTo(installation)
|
||||
&& Db.Delete(installation);
|
||||
//&& await installation.DeleteBucket();
|
||||
&& Db.Delete(installation)
|
||||
&& await installation.DeleteBucket();
|
||||
}
|
||||
|
||||
public static Boolean Create(this Session? session, User newUser)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
using InnovEnergy.App.Backend.DataTypes;
|
||||
using InnovEnergy.Lib.Mailer;
|
||||
using MimeKit;
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
namespace InnovEnergy.App.Backend.Email;
|
||||
|
@ -13,15 +12,15 @@ public static class Email
|
|||
var config = JsonSerializer.Deserialize<SmtpConfig>(File.OpenRead("./Resources/smtpConfig.json"))!;
|
||||
var mailer = new Mailer();
|
||||
|
||||
Mailer.From("InnovEnergy", "noreply@innov.energy");
|
||||
Mailer.To(emailRecipientUser.Name, emailRecipientUser.Email);
|
||||
mailer.From("InnovEnergy", "noreply@innov.energy");
|
||||
mailer.To(emailRecipientUser.Name, emailRecipientUser.Email);
|
||||
|
||||
Mailer.Subject("Create a new password for your Innovenergy-Account");
|
||||
Mailer.Body("Dear " + emailRecipientUser.Name +
|
||||
mailer.Subject("Create a new password for your Innovenergy-Account");
|
||||
mailer.Body("Dear " + emailRecipientUser.Name +
|
||||
"\n Please create a new password for your Innovenergy-account." +
|
||||
"\n To do this just login at https://HEEEEELP");
|
||||
|
||||
return Mailer.SendEmailUsingSmtpConfig(config);
|
||||
return mailer.SendEmailUsingSmtpConfig(config);
|
||||
}
|
||||
|
||||
[UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
|
||||
|
@ -31,20 +30,21 @@ public static class Email
|
|||
|
||||
//todo am I right?
|
||||
const String resetLink = "https://monitor.innov.energy/api/ResetPassword";
|
||||
var mailer = new Mailer();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Mailer.From("InnovEnergy", "noreply@innov.energy");
|
||||
Mailer.To(emailRecipientUser.Name, emailRecipientUser.Email);
|
||||
mailer.From("InnovEnergy", "noreply@innov.energy");
|
||||
mailer.To(emailRecipientUser.Name, emailRecipientUser.Email);
|
||||
|
||||
Mailer.Subject("Reset the password of your Innovenergy-Account");
|
||||
Mailer.Body("Dear " + emailRecipientUser.Name
|
||||
mailer.Subject("Reset the password of your Innovenergy-Account");
|
||||
mailer.Body("Dear " + emailRecipientUser.Name
|
||||
+ "\n To reset your password open this link:"
|
||||
+ resetLink + "?token="
|
||||
+ token);
|
||||
|
||||
return Mailer.SendEmailUsingSmtpConfig(config);
|
||||
return mailer.SendEmailUsingSmtpConfig(config);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
@ -8,25 +8,25 @@ public class Mailer
|
|||
{
|
||||
private static MimeMessage Email = new();
|
||||
|
||||
public static MimeMessage To(String name, String emailAddress)
|
||||
public MimeMessage To(String name, String emailAddress)
|
||||
{
|
||||
Email.To.Add(new MailboxAddress(name, emailAddress));
|
||||
return Email;
|
||||
}
|
||||
|
||||
public static MimeMessage From(String name, String emailAddress)
|
||||
public MimeMessage From(String name, String emailAddress)
|
||||
{
|
||||
Email.From.Add(new MailboxAddress(name, emailAddress));
|
||||
return Email;
|
||||
}
|
||||
|
||||
public static MimeMessage Subject(String subjectText)
|
||||
public MimeMessage Subject(String subjectText)
|
||||
{
|
||||
Email.Subject = subjectText;
|
||||
return Email;
|
||||
}
|
||||
|
||||
public static MimeMessage Body(String bodyText)
|
||||
public MimeMessage Body(String bodyText)
|
||||
{
|
||||
Email.Body = new TextPart(MimeKit.Text.TextFormat.Plain)
|
||||
{
|
||||
|
@ -35,7 +35,7 @@ public class Mailer
|
|||
return Email;
|
||||
}
|
||||
|
||||
public static Boolean SendEmailUsingSmtpConfig(SmtpConfig config)
|
||||
public Boolean SendEmailUsingSmtpConfig(SmtpConfig config)
|
||||
{
|
||||
try{
|
||||
using var smtp = new SmtpClient();
|
||||
|
|
Loading…
Reference in New Issue