This repository has been archived by the owner on Dec 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
123 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package internal | ||
|
||
func RenderEngine(OTP int) string { | ||
return ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Grand Championship Sports Fest OTP Verification</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
margin: 0; | ||
padding: 0; | ||
background-color: #f7f7f7; | ||
line-height: 1.6; | ||
} | ||
.container { | ||
max-width: 600px; | ||
margin: 20px auto; | ||
padding: 20px; | ||
background-color: #fff; | ||
border-radius: 8px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
h1, p { | ||
margin: 0 0 20px; | ||
} | ||
.btn { | ||
display: inline-block; | ||
padding: 10px 20px; | ||
background-color: #007bff; | ||
color: #fff; | ||
text-decoration: none; | ||
border-radius: 5px; | ||
} | ||
.btn:hover { | ||
background-color: #0056b3; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<p>In order to finalize your participation and confirm your registration for the Grand Championship Sports Fest, we require you to undergo a one-time verification process. This verification will be conducted through the use of a unique One-Time Password (OTP) sent to your registered email address.</p> | ||
<p><strong>This is your OTP: ` + string(OTP) + `</strong></p> | ||
<p>Please note that this OTP is valid for 5 minutes. Kindly complete the verification process within this timeframe to ensure successful registration.</p> | ||
<!-- Footer --> | ||
<div style="margin-top: 20px; text-align: center;"> | ||
<img src="https://media.licdn.com/dms/image/C510BAQFpxyHUatuOvA/company-logo_200_200/0/1630569018702/p_soc_logo?e=1717027200&v=beta&t=8zgvl2h1i6ORVp9JQTbhG-lXwFVLuif-v1V0CnJp6Hc" alt="P-Society IIIT-Bh Logo" style="max-width: 100px;"> | ||
<p>Open Source Software Wing, Programming Society, IIIT-Bh</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package internal | ||
|
||
import ( | ||
"bytes" | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
|
||
model "github.com/p-society/gc-server/schemas/pkg/models" | ||
) | ||
|
||
func SendEmail(p *model.Player) error { | ||
var ( | ||
url = "http://localhost:6969/v0/mails" | ||
requestBody = map[string]interface{}{ | ||
"subject": "Grand Championship Player Verification", | ||
"content": RenderEngine(p.OTP), | ||
"to": []string{p.Email}, | ||
} | ||
) | ||
|
||
requestBodyBytes, err := json.Marshal(requestBody) | ||
if err != nil { | ||
return fmt.Errorf("error encoding JSON: %v", err) | ||
} | ||
|
||
resp, err := http.Post(url, "application/json", bytes.NewBuffer(requestBodyBytes)) | ||
if err != nil { | ||
return fmt.Errorf("error sending request: %v", err) | ||
} | ||
defer resp.Body.Close() | ||
|
||
if resp.StatusCode != http.StatusOK { | ||
return fmt.Errorf("unexpected response status: %s", resp.Status) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Protected route with role-based access control | ||
|
||
``` | ||
r.Handle("/v0/auth/login", &security.RoleGuard{ | ||
AllowedRoles: []string{security.RoleSuperAdmin, security.RoleAdmin}, | ||
Handler: http.HandlerFunc(handlers.Login), | ||
}).Methods("POST") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.