Skip to content

Commit fce27ce

Browse files
committed
added base url to invite
1 parent 9160722 commit fce27ce

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

service/auth.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"time"
77

88
"github.com/UDCS/Autograder/models"
9+
"github.com/UDCS/Autograder/utils/config"
910
"github.com/UDCS/Autograder/utils/email"
1011
"github.com/UDCS/Autograder/utils/jwt_token"
1112
"github.com/UDCS/Autograder/utils/logger"
@@ -38,10 +39,12 @@ func (app *GraderApp) CreateInvitation(jwksToken string, invitation models.Invit
3839
return nil, err
3940
}
4041

42+
baseUrl := config.GetBaseURL()
43+
4144
// TODO: email the invitation with the link containg both token and invitation I
4245
//email.Send("auth/register/" + invitation.Id.String() + "?token=" + token)
4346
//msg := "Subject: Create an Autograder Account\n\nYour professor has invited you to create an Autograder account.\n\nYou may create the account be visitting auth/regiser/" + invitation.Id.String() + "?token=" + token + "\n\nThis email cannot be replied to. If you have any questions, please contact your professor."
44-
msg := fmt.Sprintf("Subject: Create an Autograder Account\nYour professor has invited you to create an Autograder account.\n\nYou may create the account be visitting https://udcs-autograder.web.app/auth/regiser/%s?token=%s\n\nThis email cannot be replied to. If you have any questions, please contact your professor.", invitation.Id.String(), token)
47+
msg := fmt.Sprintf("Subject: Create an Autograder Account\nYour professor has invited you to create an Autograder account.\n\nYou may create the account be visiting %s/signup?id=%s&token=%s\n\nThis email cannot be replied to. If you have any questions, please contact your professor.", baseUrl, invitation.Id.String(), token)
4548
err = email.Send(invitation.Email, msg)
4649
if err != nil {
4750
fmt.Print(err.Error())
@@ -77,7 +80,8 @@ func (app *GraderApp) InviteAdmin(invitation models.Invitation) (*models.Invitat
7780
"Subject: Create an Admin Autograder Account\n\nAn Autograder admin has invited you to create an admin Autograder account.\n\nYou may create the account be visitting auth/regiser/"
7881
+ invitation.Id.String() + "?token=" + token +
7982
"\n\nThis email cannot be replied to. If you have any questions, please contact the admin."*/
80-
msg := fmt.Sprintf("Subject: Create an Admin Autograder Account\nAn Autograder admin has invited you to create an Autograder account.\n\nYou may create the account be visitting https://udcs-autograder.web.app/auth/regiser/%s?token=%s\n\nThis email cannot be replied to. If you have any questions, please contact the admin.", invitation.Id.String(), token)
83+
baseUrl := config.GetBaseURL()
84+
msg := fmt.Sprintf("Subject: Create an Admin Autograder Account\nAn Autograder admin has invited you to create an Autograder account.\n\nYou may create the account be visiting %s/signup?id=%s&token=%s\n\nThis email cannot be replied to. If you have any questions, please contact the admin.", baseUrl, invitation.Id.String(), token)
8185
err = email.Send(invitation.Email, msg)
8286

8387
if err != nil {

utils/config/config.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package config
22

33
import (
4+
"os"
45
"strings"
56
"sync"
67
"time"
@@ -64,3 +65,11 @@ func GetConfig() *Config {
6465

6566
return configInstance
6667
}
68+
69+
func GetBaseURL() string {
70+
url := os.Getenv("BASE_URL")
71+
if url == "" {
72+
return "http://localhost:8080"
73+
}
74+
return url
75+
}

0 commit comments

Comments
 (0)