email users their id
This commit is contained in:
4 files changed
+134
-1
No files matched your search
@@ -246,6 +246,18 @@ func Enroll(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
student.SchoolData.SID = sid
|
student.SchoolData.SID = sid
|
||||||
|
|
||||||
|
// Send student personal email student ID
|
||||||
|
subject = "Account Registered"
|
||||||
|
r = NewRequest([]string{receiver}, subject)
|
||||||
|
|
||||||
|
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": student.PersonalData.FirstName, "id": sid, "userType": "student"}); !sent {
|
||||||
|
cancel()
|
||||||
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
|
"success": false,
|
||||||
|
"message": "Could not send ID to students email",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
var pen string
|
var pen string
|
||||||
for {
|
for {
|
||||||
pen = GenerateID(9)
|
pen = GenerateID(9)
|
||||||
@@ -382,6 +394,18 @@ func RegisterTeacher(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
teacher.SchoolData.TID = tid
|
teacher.SchoolData.TID = tid
|
||||||
|
|
||||||
|
// Send teacher personal email student ID
|
||||||
|
subject = "Account Registered"
|
||||||
|
r = NewRequest([]string{receiver}, subject)
|
||||||
|
|
||||||
|
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": teacher.PersonalData.FirstName, "id": tid, "userType": "teacher"}); !sent {
|
||||||
|
cancel()
|
||||||
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
|
"success": false,
|
||||||
|
"message": "Could not send ID to teachers email",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
teacher.Created_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
teacher.Created_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
teacher.Updated_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
teacher.Updated_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
teacher.ID = primitive.NewObjectID()
|
teacher.ID = primitive.NewObjectID()
|
||||||
@@ -454,7 +478,7 @@ func CreateAdmin(c *fiber.Ctx) error {
|
|||||||
cancel()
|
cancel()
|
||||||
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
"success": false,
|
"success": false,
|
||||||
"message": "Could not send password to students email",
|
"message": "Could not send password to admins email",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,6 +491,18 @@ func CreateAdmin(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
admin.AID = aid
|
admin.AID = aid
|
||||||
|
|
||||||
|
// Send student personal email student ID
|
||||||
|
subject = "Account Registered"
|
||||||
|
r = NewRequest([]string{receiver}, subject)
|
||||||
|
|
||||||
|
if sent := r.Send("./templates/accountRegisreded.html", map[string]string{"username": admin.FirstName, "id": aid, "userType": "admin"}); !sent {
|
||||||
|
cancel()
|
||||||
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{
|
||||||
|
"success": false,
|
||||||
|
"message": "Could not send ID to admins email",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
admin.Created_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
admin.Created_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
admin.Updated_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
admin.Updated_at, _ = time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
|
||||||
admin.ID = primitive.NewObjectID()
|
admin.ID = primitive.NewObjectID()
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ type Student struct {
|
|||||||
PhotoName string `json:"photoname"` // name of photo in db
|
PhotoName string `json:"photoname"` // name of photo in db
|
||||||
} `json:"schooldata"`
|
} `json:"schooldata"`
|
||||||
AccountData struct {
|
AccountData struct {
|
||||||
|
VerifiedEmail bool `json:"verifiedemail"`
|
||||||
SchoolEmail string `json:"schoolemail"`
|
SchoolEmail string `json:"schoolemail"`
|
||||||
Password string `json:"-" validate:"min=10,max=32"`
|
Password string `json:"-" validate:"min=10,max=32"`
|
||||||
AccountDisabled bool `bson:"accountdisabled"`
|
AccountDisabled bool `bson:"accountdisabled"`
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ type Teacher struct {
|
|||||||
PhotoName string `json:"photoname"` // name of photo in db
|
PhotoName string `json:"photoname"` // name of photo in db
|
||||||
} `json:"schooldata"`
|
} `json:"schooldata"`
|
||||||
AccountData struct {
|
AccountData struct {
|
||||||
|
VerifiedEmail bool `json:"verifiedemail"`
|
||||||
SchoolEmail string `json:"schoolemail"`
|
SchoolEmail string `json:"schoolemail"`
|
||||||
Password string `json:"-" validate:"min=10,max=32"`
|
Password string `json:"-" validate:"min=10,max=32"`
|
||||||
AccountDisabled bool `bson:"accountdisabled"`
|
AccountDisabled bool `bson:"accountdisabled"`
|
||||||
|
|||||||
@@ -0,0 +1,95 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width"/>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||||
|
<title>Account Registered</title>
|
||||||
|
<style type="text/css">
|
||||||
|
body{
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0;
|
||||||
|
min-width: 100%;
|
||||||
|
font-family: sans-serif;
|
||||||
|
}
|
||||||
|
table{
|
||||||
|
margin: 50px 0 50px 0;
|
||||||
|
}
|
||||||
|
.header{
|
||||||
|
height: 40px;
|
||||||
|
text-align: center;
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.content{
|
||||||
|
height: 100px;
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 30px;
|
||||||
|
}
|
||||||
|
.subscribe{
|
||||||
|
height: 70px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.button{
|
||||||
|
text-align: center;
|
||||||
|
font-size: 18px;
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-weight: bold;
|
||||||
|
padding: 0 30px 0 30px;
|
||||||
|
}
|
||||||
|
.button a{
|
||||||
|
color: #FFFFFF;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
.buttonwrapper{
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
.footer{
|
||||||
|
text-transform: uppercase;
|
||||||
|
text-align: center;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.footer a{
|
||||||
|
color: #000000;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body bgcolor="#009587">
|
||||||
|
<table bgcolor="#FFFFFF" width="100%" border="0" cellspacing="0" cellpadding="0">
|
||||||
|
<tr class="header">
|
||||||
|
<td style="padding: 40px;">
|
||||||
|
Account Registered
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="content">
|
||||||
|
<td style="padding:10px;">
|
||||||
|
<p>
|
||||||
|
Hi <b>{{ .username }}</b>, <br/>
|
||||||
|
Your account has been registered into the system. You can now log into your account.
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="subscribe">
|
||||||
|
<td style="padding: 20px 0 0 0;">
|
||||||
|
<h3>Your {{ .userType }} ID is:</h3>
|
||||||
|
<table bgcolor="#009587" border="0" cellspacing="0" cellpadding="0" class="buttonwrapper">
|
||||||
|
<tr>
|
||||||
|
<td class="button" height="45">
|
||||||
|
{{ .id }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr class="footer">
|
||||||
|
<td style="padding: 40px;">
|
||||||
|
This is an automated system email // DO NOT REPLY
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in new issue
Block a user