From 6723108e48c5b15f819dbff245ce37a97e4abb52 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 23 Oct 2023 16:35:43 +0200 Subject: [PATCH] Lets try deploy again --- .gitea/workflows/prod-deploy.yaml | 8 +++----- .gitea/workflows/stage-deploy.yaml | 4 ++-- csharp/App/Backend/Controller.cs | 14 ++++---------- csharp/App/Backend/Database/Db.cs | 4 ++-- csharp/App/Backend/Email/Email.cs | 6 +++--- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.gitea/workflows/prod-deploy.yaml b/.gitea/workflows/prod-deploy.yaml index 647c1be88..fb59bb9a5 100644 --- a/.gitea/workflows/prod-deploy.yaml +++ b/.gitea/workflows/prod-deploy.yaml @@ -21,11 +21,6 @@ jobs: - run: | npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 install npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 run build - - uses: burnett01/rsync-deployments@6.0.0 - - run: | - cd ${{ gitea.workspace }} - rsync -av ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ ubuntu@${{ secrets.PRODUCTION_SSH_HOST }}:~/backend - rsync -av ./typescript/frontend-marios2/* ubuntu@${{ secrets.PRODUCTION_SSH_HOST }}:~/frontend/ - name: Configure SSH run: | mkdir -p ~/.ssh/ @@ -43,6 +38,9 @@ jobs: SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} - run: | + cd ${{ gitea.workspace }} + scp -r ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ production:~/backend + scp -r ./typescript/frontend-marios2/* production:~/frontend/ ssh production 'sudo systemctl restart backend' ssh production 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' ssh production 'sudo npm install -g serve' diff --git a/.gitea/workflows/stage-deploy.yaml b/.gitea/workflows/stage-deploy.yaml index 47a8845fa..0199b7c17 100644 --- a/.gitea/workflows/stage-deploy.yaml +++ b/.gitea/workflows/stage-deploy.yaml @@ -39,8 +39,8 @@ jobs: SSH_HOST: ${{ secrets.STAGING_SSH_HOST }} - run: | cd ${{ gitea.workspace }} - scp -rp ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend - scp -rp ./typescript/frontend-marios2/* staging:~/frontend/ + scp -r ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend + scp -r ./typescript/frontend-marios2/* staging:~/frontend/ ssh staging 'sudo systemctl restart backend' ssh staging 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' ssh staging 'sudo npm install -g serve' diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index 35c46d9d8..738031da3 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -258,9 +258,8 @@ public class Controller : ControllerBase public ActionResult CreateUser([FromBody] User newUser, Token authToken) { var create = Db.GetSession(authToken).Create(newUser); - var session = new Session(Db.GetUserByEmail(newUser.Email)!); - var res = Db.Create(session); - return res && create && Db.SendNewUserEmail(newUser, session.Token) + + return create && Db.SendNewUserEmail(newUser) ? newUser.HidePassword() : Unauthorized() ; } @@ -495,14 +494,9 @@ public class Controller : ControllerBase } [HttpGet(nameof(NewUserLogin))] - public ActionResult NewUserLogin(Token token) + public ActionResult NewUserLogin(String email) { - var user = Db.GetSession(token)?.User; - - if (user is null) - return Unauthorized(); - - return Redirect($"https://monitor.innov.energy/?username={user.Email}"); + return Redirect($"https://monitor.innov.energy/?username={email}"); } } diff --git a/csharp/App/Backend/Database/Db.cs b/csharp/App/Backend/Database/Db.cs index 51f82efe5..425389706 100644 --- a/csharp/App/Backend/Database/Db.cs +++ b/csharp/App/Backend/Database/Db.cs @@ -177,9 +177,9 @@ public static partial class Db return Email.Email.SendPasswordResetMessage(user, sessionToken); } - public static Boolean SendNewUserEmail(User user, String sessionToken) + public static Boolean SendNewUserEmail(User user) { - return Email.Email.SendNewUserMessage(user, sessionToken); + return Email.Email.SendNewUserMessage(user); } public static Boolean DeleteUserPassword(User user) diff --git a/csharp/App/Backend/Email/Email.cs b/csharp/App/Backend/Email/Email.cs index 188a49bd7..ae22ce77c 100644 --- a/csharp/App/Backend/Email/Email.cs +++ b/csharp/App/Backend/Email/Email.cs @@ -54,7 +54,7 @@ public static class Email [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "")] - public static Boolean SendNewUserMessage (User emailRecipientUser, String token) + public static Boolean SendNewUserMessage (User emailRecipientUser) { var config = JsonSerializer.Deserialize(File.OpenRead("./Resources/smtpConfig.json"))!; @@ -71,8 +71,8 @@ public static class Email mailer.Subject("Your new Innovenergy-Account"); mailer.Body("Dear " + emailRecipientUser.Name + "\n To set your password and log in to your Innovenergy-Account open this link:" - + resetLink + "?token=" - + token); + + resetLink + "?email=" + + emailRecipientUser.Email); return mailer.SendEmailUsingSmtpConfig(config); }