Added new user setup
This commit is contained in:
parent
d402714b59
commit
93b56bf1cc
|
@ -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.STAGING_SSH_HOST }}:~/backend
|
|
||||||
rsync -av ./typescript/frontend-marios2/* ubuntu@${{ secrets.STAGING_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.STAGING_SSH_KEY }}
|
SSH_KEY: ${{ secrets.STAGING_SSH_KEY }}
|
||||||
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
|
SSH_HOST: ${{ secrets.STAGING_SSH_HOST }}
|
||||||
- run: |
|
- run: |
|
||||||
|
cd ${{ gitea.workspace }}
|
||||||
|
rsync -av ./csharp/App/Backend/bin/Release/net6.0/linux-x64/publish/ staging:~/backend
|
||||||
|
rsync -av ./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'
|
||||||
|
|
|
@ -257,7 +257,10 @@ public class Controller : ControllerBase
|
||||||
[HttpPost(nameof(CreateUser))]
|
[HttpPost(nameof(CreateUser))]
|
||||||
public ActionResult<User> CreateUser([FromBody] User newUser, Token authToken)
|
public ActionResult<User> CreateUser([FromBody] User newUser, Token authToken)
|
||||||
{
|
{
|
||||||
return Db.GetSession(authToken).Create(newUser)
|
|
||||||
|
var session = new Session(newUser);
|
||||||
|
var res = Db.Create(session);
|
||||||
|
return res && Db.GetSession(authToken).Create(newUser) && Db.SendNewUserEmail(newUser, session.Token)
|
||||||
? newUser.HidePassword()
|
? newUser.HidePassword()
|
||||||
: Unauthorized() ;
|
: Unauthorized() ;
|
||||||
}
|
}
|
||||||
|
@ -491,6 +494,17 @@ public class Controller : ControllerBase
|
||||||
return Redirect($"https://monitor.innov.energy/?username={user.Email}");
|
return Redirect($"https://monitor.innov.energy/?username={user.Email}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet(nameof(NewUserLogin))]
|
||||||
|
public ActionResult<Object> NewUserLogin(Token token)
|
||||||
|
{
|
||||||
|
var user = Db.GetSession(token)?.User;
|
||||||
|
|
||||||
|
if (user is null)
|
||||||
|
return Unauthorized();
|
||||||
|
// Console.WriteLine("HELP");
|
||||||
|
return Redirect($"https://monitor.innov.energy/?username={user.Email}");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,11 @@ 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)
|
||||||
|
{
|
||||||
|
return Email.Email.SendNewUserMessage(user, sessionToken);
|
||||||
|
}
|
||||||
|
|
||||||
public static Boolean DeleteUserPassword(User user)
|
public static Boolean DeleteUserPassword(User user)
|
||||||
{
|
{
|
||||||
user.Password = "";
|
user.Password = "";
|
||||||
|
|
|
@ -51,4 +51,34 @@ public static class Email
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[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)
|
||||||
|
{
|
||||||
|
var config = JsonSerializer.Deserialize<SmtpConfig>(File.OpenRead("./Resources/smtpConfig.json"))!;
|
||||||
|
|
||||||
|
//todo am I right?
|
||||||
|
const String resetLink = "https://monitor.innov.energy/api/NewUserLogin";
|
||||||
|
var mailer = new Mailer();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
mailer.From("InnovEnergy", "noreply@innov.energy");
|
||||||
|
mailer.To(emailRecipientUser.Name, emailRecipientUser.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);
|
||||||
|
|
||||||
|
return mailer.SendEmailUsingSmtpConfig(config);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue