add: verification status page

This commit is contained in:
$(pass /github/name)
2024-07-12 12:07:38 +02:00
parent 03a2b3bdc5
commit 18d91d396b
10 changed files with 242 additions and 26 deletions

1
.gitignore vendored
View File

@@ -36,6 +36,7 @@ go.work
!*.go !*.go
!*.html !*.html
!*.css
!go.sum !go.sum
!go.mod !go.mod
!*.sql !*.sql

View File

@@ -40,7 +40,6 @@ func (uc *UserController) RegisterUser(c *gin.Context) {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Not a valid subscription model"}) c.JSON(http.StatusInternalServerError, gin.H{"error": "Not a valid subscription model"})
return return
} }
regData.User.Membership.SubscriptionModel = *selectedModel regData.User.Membership.SubscriptionModel = *selectedModel
// Register User // Register User
id, token, err := uc.Service.RegisterUser(&regData.User) id, token, err := uc.Service.RegisterUser(&regData.User)
@@ -51,14 +50,6 @@ func (uc *UserController) RegisterUser(c *gin.Context) {
} }
regData.User.ID = id regData.User.ID = id
// Register Bank Account
/* _, err = uc.BankAccountService.RegisterBankAccount(&regData.User.BankAccount)
if err != nil {
logger.Error.Printf("Couldn't register bank account: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Couldn't register User-BankAccount"})
return
} */
// Register Consents // Register Consents
var consents = [2]models.Consent{ var consents = [2]models.Consent{
{ {
@@ -83,14 +74,6 @@ func (uc *UserController) RegisterUser(c *gin.Context) {
} }
} }
// Register Membership
/* _, err = uc.MembershipService.RegisterMembership(&regData.User.Membership)
if err != nil {
logger.Error.Printf("Couldn't register membership: %v", err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Couldn't register User-membership"})
return
} */
// Send notifications // Send notifications
if err := uc.EmailService.SendVerificationEmail(&regData.User, &token); err != nil { if err := uc.EmailService.SendVerificationEmail(&regData.User, &token); err != nil {
logger.Error.Printf("Failed to send email verification email to user: %v", err) logger.Error.Printf("Failed to send email verification email to user: %v", err)
@@ -113,26 +96,26 @@ func (uc *UserController) VerifyMailHandler(c *gin.Context) {
token := c.Query("token") token := c.Query("token")
if token == "" { if token == "" {
logger.Error.Println("Missing token to verify mail") logger.Error.Println("Missing token to verify mail")
c.JSON(http.StatusNoContent, gin.H{"error": "Missing token"}) c.HTML(http.StatusBadRequest, "verification_error.html", gin.H{"ErrorMessage": "Missing token"})
return return
} }
user, err := uc.Service.VerifyUser(&token) user, err := uc.Service.VerifyUser(&token)
if err != nil { if err != nil {
logger.Error.Printf("Cannot verify user: %v", err) logger.Error.Printf("Cannot verify user: %v", err)
c.JSON(http.StatusUnauthorized, gin.H{"error": "Cannot verify user"}) c.HTML(http.StatusUnauthorized, "verification_error.html", gin.H{"ErrorMessage": "Emailadresse wurde schon bestätigt. Sollte dies nicht der Fall sein, wende Dich bitte an info@carsharing-hasloh.de."})
return return
} }
membership, err := uc.MembershipService.FindMembershipByUserID(user.ID) membership, err := uc.MembershipService.FindMembershipByUserID(user.ID)
if err != nil { if err != nil {
logger.Error.Printf("Cannot get membership of user %v: %v", user.ID, err) logger.Error.Printf("Cannot get membership of user %v: %v", user.ID, err)
c.JSON(http.StatusInternalServerError, gin.H{"error": "Cannot get Membership of user"}) c.HTML(http.StatusInternalServerError, "verifiction_error.html", gin.H{"ErrorMessage": "Nutzer konnte nicht gefunden werden.. Merkwürdig.. wende Dich bitte an info@carsharing-hasloh.de."})
return return
} }
uc.EmailService.SendWelcomeEmail(user, membership) uc.EmailService.SendWelcomeEmail(user, membership)
c.Status(http.StatusOK) c.HTML(http.StatusOK, "verification_success.html", gin.H{"FirstName": user.FirstName})
} }

View File

@@ -7,9 +7,9 @@ type Membership struct {
UpdatedAt time.Time UpdatedAt time.Time
StartDate time.Time `json:"start_date"` StartDate time.Time `json:"start_date"`
EndDate time.Time `json:"end_date"` EndDate time.Time `json:"end_date"`
Children *[]User `gorm:"foreignKey:ParentMemberID"`
Status string `json:"status"` Status string `json:"status"`
SubscriptionModel SubscriptionModel `gorm:"foreignKey:SubscriptionModelID" json:"subscription_model"` SubscriptionModel SubscriptionModel `gorm:"foreignKey:SubscriptionModelID" json:"subscription_model"`
ParentMembershipID int64 `json:"parent_member_id" validate:"omitempty,omitnil,number"`
SubscriptionModelID int64 `json:"subsription_model_id"` SubscriptionModelID int64 `json:"subsription_model_id"`
ID int64 `json:"id"` ID int64 `json:"id"`
UserID int64 `json:"user_id"` UserID int64 `json:"user_id"`

View File

@@ -25,7 +25,6 @@ type User struct {
BankAccount BankAccount `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"bank_account"` BankAccount BankAccount `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"bank_account"`
Verification Verification `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"` Verification Verification `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
Membership Membership `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"membership"` Membership Membership `gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"membership"`
ParentMemberID int64 `json:"parent_member_id" validate:"omitempty,number"`
ID int64 `gorm:"primaryKey"` ID int64 `gorm:"primaryKey"`
PaymentStatus int8 `json:"payment_status"` PaymentStatus int8 `json:"payment_status"`
Status int8 `json:"status"` Status int8 `json:"status"`

View File

@@ -43,6 +43,9 @@ func Run() {
router := gin.Default() router := gin.Default()
// gin.SetMode(gin.ReleaseMode) // gin.SetMode(gin.ReleaseMode)
router.Static("/templates/css", "./style")
// Load HTML templates
router.LoadHTMLGlob("templates/html/*")
router.Use(gin.Logger()) router.Use(gin.Logger())
// router.Use(middlewares.LoggerMiddleware()) // router.Use(middlewares.LoggerMiddleware())

28
templates/css/style.css Normal file
View File

@@ -0,0 +1,28 @@
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
color: #333;
margin: 0;
padding: 0;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
h1 {
color: #0056b3;
text-align: center;
}
p {
font-size: 18px;
line-height: 1.6;
}
.error-message {
color: red;
font-weight: bold;
}

View File

@@ -53,7 +53,7 @@
<div style="font-weight: normal; padding: 0px 24px 16px 24px"> <div style="font-weight: normal; padding: 0px 24px 16px 24px">
<p> <p>
Ein neues Mitglied!!!<br />{{.FirstName}} {{.LastName}} hat Ein neues Mitglied!!!<br />{{.FirstName}} {{.LastName}} hat
sich regitriert. sich registriert.
</p> </p>
</div> </div>
<div <div

View File

@@ -70,7 +70,7 @@
</div> </div>
<div style="text-align: center; padding: 16px 24px 16px 24px"> <div style="text-align: center; padding: 16px 24px 16px 24px">
<a <a
href="https://carsharing-hasloh/backend/api/verify?token={{.Token}}" href="https://carsharing-hasloh/backend/verify?token={{.Token}}"
style=" style="
color: #ffffff; color: #ffffff;
font-size: 26px; font-size: 26px;
@@ -122,7 +122,7 @@
padding: 4px 24px 16px 24px; padding: 4px 24px 16px 24px;
" "
> >
https://carsharing-hasloh/backend/api/verify?token={{.Token}} https://carsharing-hasloh/backend/verify?token={{.Token}}
</div> </div>
<div style="font-weight: normal; padding: 16px 24px 16px 24px"> <div style="font-weight: normal; padding: 16px 24px 16px 24px">
Nachdem wir Ihre E-Mail Adresse bestätigen konnten, schicken wir Nachdem wir Ihre E-Mail Adresse bestätigen konnten, schicken wir

View File

@@ -0,0 +1,108 @@
<!doctype html>
<html>
<body style="background-color: #f2f5f7">
<div
style="
color: #242424;
font-family: &quot;Helvetica Neue&quot;, &quot;Arial Nova&quot;,
&quot;Nimbus Sans&quot;, Arial, sans-serif;
font-size: 16px;
font-weight: 400;
letter-spacing: 0.15008px;
line-height: 1.5;
margin: 0;
padding: 32px 0;
min-height: 100%;
width: 100%;
"
>
<table
align="center"
width="100%"
style="margin: 0 auto; max-width: 600px; background-color: #ffffff"
role="presentation"
cellspacing="0"
cellpadding="0"
border="0"
>
<tbody>
<tr style="width: 100%">
<td>
<div style="padding: 0px 24px 0px 24px">
<a
href="https://carsharing-hasloh.de"
style="text-decoration: none"
target="_blank"
><img
alt="Carsharing-Hasloh"
src="https://carsharing-hasloh.de/images/CarsharingSH-Hasloh-LOGO.jpeg"
style="
outline: none;
border: none;
text-decoration: none;
vertical-align: middle;
display: inline-block;
max-width: 100%;
"
/></a>
</div>
<h1
style="
font-weight: bold;
text-align: center;
margin: 0;
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-size: 32px;
padding: 40px 24px 40px 24px;
"
>
So ein Mist!
</h1>
<div
style="
font-size: 48px;
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: normal;
text-align: center;
padding: 0px 24px 24px 24px;
"
>
🧐
</div>
<div
style="
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: bold;
text-align: center;
padding: 0px 24px 16px 24px;
"
>
Da ist etwas schiefgelaufen, wir konnten Deine E-Mail Adresse
nicht bestätigen:
</div>
<div
style="
font-size: 17px;
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: normal;
text-align: center;
padding: 0px 24px 80px 24px;
"
>
{{ .ErrorMessage }}
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>

View File

@@ -0,0 +1,94 @@
<!doctype html>
<html>
<body style="background-color: #f2f5f7">
<div
style="
color: #242424;
font-family: &quot;Helvetica Neue&quot;, &quot;Arial Nova&quot;,
&quot;Nimbus Sans&quot;, Arial, sans-serif;
font-size: 16px;
font-weight: 400;
letter-spacing: 0.15008px;
line-height: 1.5;
margin: 0;
padding: 32px 0;
min-height: 100%;
width: 100%;
"
>
<table
align="center"
width="100%"
style="margin: 0 auto; max-width: 600px; background-color: #ffffff"
role="presentation"
cellspacing="0"
cellpadding="0"
border="0"
>
<tbody>
<tr style="width: 100%">
<td>
<div style="padding: 0px 24px 0px 24px">
<a
href="https://carsharing-hasloh.de"
style="text-decoration: none"
target="_blank"
><img
alt="Carsharing-Hasloh"
src="https://carsharing-hasloh.de/images/CarsharingSH-Hasloh-LOGO.jpeg"
style="
outline: none;
border: none;
text-decoration: none;
vertical-align: middle;
display: inline-block;
max-width: 100%;
"
/></a>
</div>
<div
style="
font-size: 23px;
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: normal;
text-align: center;
padding: 36px 24px 36px 24px;
"
>
Herzlich Willkommen {{.FirstName}}👋,
</div>
<div
style="
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: bold;
text-align: center;
padding: 0px 24px 16px 24px;
"
>
Vielen Dank für die Registrierung Deiner E-Mail Adresse.
</div>
<div
style="
font-size: 17px;
font-family: Seravek, &quot;Gill Sans Nova&quot;, Ubuntu,
Calibri, &quot;DejaVu Sans&quot;, source-sans-pro,
sans-serif;
font-weight: normal;
text-align: center;
padding: 0px 24px 80px 24px;
"
>
Weitere Informationen wurden soeben an Deine E-Mail Adresse
gesandt!
</div>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>