Lets try deploy again

This commit is contained in:
Kim 2023-10-23 16:35:43 +02:00
parent 17aa45ae27
commit 6723108e48
5 changed files with 14 additions and 22 deletions

View File

@ -21,11 +21,6 @@ jobs:
- run: | - run: |
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 install npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 install
npm --prefix ${{ gitea.workspace }}/typescript/frontend-marios2 run build 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 - name: Configure SSH
run: | run: |
mkdir -p ~/.ssh/ mkdir -p ~/.ssh/
@ -43,6 +38,9 @@ jobs:
SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }}
SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }}
- run: | - 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 systemctl restart backend'
ssh production 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' ssh production 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/'
ssh production 'sudo npm install -g serve' ssh production 'sudo npm install -g serve'

View File

@ -39,8 +39,8 @@ jobs:
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }} SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
- run: | - run: |
cd ${{ gitea.workspace }} cd ${{ gitea.workspace }}
scp -rp ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend scp -r ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend
scp -rp ./typescript/frontend-marios2/* staging:~/frontend/ scp -r ./typescript/frontend-marios2/* staging:~/frontend/
ssh staging 'sudo systemctl restart backend' ssh staging 'sudo systemctl restart backend'
ssh staging 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/' ssh staging 'sudo cp -rf ~/frontend/build/* /var/www/html/monitor.innov.energy/html/'
ssh staging 'sudo npm install -g serve' ssh staging 'sudo npm install -g serve'

View File

@ -258,9 +258,8 @@ public class Controller : ControllerBase
public ActionResult<User> CreateUser([FromBody] User newUser, Token authToken) public ActionResult<User> CreateUser([FromBody] User newUser, Token authToken)
{ {
var create = Db.GetSession(authToken).Create(newUser); var create = Db.GetSession(authToken).Create(newUser);
var session = new Session(Db.GetUserByEmail(newUser.Email)!);
var res = Db.Create(session); return create && Db.SendNewUserEmail(newUser)
return res && create && Db.SendNewUserEmail(newUser, session.Token)
? newUser.HidePassword() ? newUser.HidePassword()
: Unauthorized() ; : Unauthorized() ;
} }
@ -495,14 +494,9 @@ public class Controller : ControllerBase
} }
[HttpGet(nameof(NewUserLogin))] [HttpGet(nameof(NewUserLogin))]
public ActionResult<Object> NewUserLogin(Token token) public ActionResult<Object> NewUserLogin(String email)
{ {
var user = Db.GetSession(token)?.User; return Redirect($"https://monitor.innov.energy/?username={email}");
if (user is null)
return Unauthorized();
return Redirect($"https://monitor.innov.energy/?username={user.Email}");
} }
} }

View File

@ -177,9 +177,9 @@ public static partial class Db
return Email.Email.SendPasswordResetMessage(user, sessionToken); 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) public static Boolean DeleteUserPassword(User user)

View File

@ -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 = "<Pending>")] [UnconditionalSuppressMessage("Trimming", "IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code", Justification = "<Pending>")]
public static Boolean SendNewUserMessage (User emailRecipientUser, String token) public static Boolean SendNewUserMessage (User emailRecipientUser)
{ {
var config = JsonSerializer.Deserialize<SmtpConfig>(File.OpenRead("./Resources/smtpConfig.json"))!; var config = JsonSerializer.Deserialize<SmtpConfig>(File.OpenRead("./Resources/smtpConfig.json"))!;
@ -71,8 +71,8 @@ public static class Email
mailer.Subject("Your new Innovenergy-Account"); mailer.Subject("Your new Innovenergy-Account");
mailer.Body("Dear " + emailRecipientUser.Name mailer.Body("Dear " + emailRecipientUser.Name
+ "\n To set your password and log in to your Innovenergy-Account open this link:" + "\n To set your password and log in to your Innovenergy-Account open this link:"
+ resetLink + "?token=" + resetLink + "?email="
+ token); + emailRecipientUser.Email);
return mailer.SendEmailUsingSmtpConfig(config); return mailer.SendEmailUsingSmtpConfig(config);
} }