Spaces:
Configuration error
Configuration error
Commit ·
8c37caf
1
Parent(s): aabd743
Deploy files from GitHub repository
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- controller/auth/auth_forgot_password_controller.go+1-1
- models/request_model.go+1-1
- models/response_model.go+10
- services/forgot_password_service.go+7-3
- space/controller/auth/auth_external_controller.go+1-1
- space/controller/auth/auth_forgot_password_controller.go+28
- space/controller/email/email_validate_controller.go-1
- space/models/request_model.go+9-4
- space/repositories/account_repository.go+2-4
- space/router/auth_route.go+2
- space/services/authentication_service.go+2-1
- space/services/email_verification_service.go+5-1
- space/services/external_authentication_service.go+6-1
- space/services/forgot_password_service.goAdded+105
- space/services/user_profile_service.go+20-5
- space/space/space/services/email_verification_service.go+11-60
- space/space/space/space/space/services/email_verification_service.go+60-11
- space/space/space/space/space/space/services/user_profile_service.go+3-1
- space/space/space/space/space/space/space/models/request_model.go+4-2
- space/space/space/space/space/space/space/services/authentication_service.go+2
- space/space/space/space/space/space/space/services/email_verification_service.go+4
- space/space/space/space/space/space/space/services/user_profile_service.go+5-2
- space/space/space/space/space/space/space/space/repositories/account_repository.go+9
- space/space/space/space/space/space/space/space/services/external_authentication_service.go+1-1
- space/space/space/space/space/space/space/space/services/user_profile_service.go+8
- space/space/space/space/space/space/space/space/space/services/user_profile_service.go+8-2
- space/space/space/space/space/space/space/space/space/space/docker-compose.yml+1-1
- space/space/space/space/space/space/space/space/space/space/space/space/Dockerfile+3
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/user/user_profile_controller.go+1-1
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/user/user_update_profile_controller.go+2-4
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/logs/error_log.txt+1
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go-3
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/models/response_model.go+5
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/repositories/account_repository.go-4
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/repositories/forgot_password_repository.goAdded+22
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/router/router.go+8-1
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/services/external_authentication_service.go+4-5
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/services/user_profile_service.go+50-6
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/.gitignore+4-2
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/config/config.go+10
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/config/database_connection_config.go+4
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/auth/auth_external_controller.goAdded+20
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/auth/auth_forgot_password_controller.goAdded+1
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/email/email_create_verification_controller.goAdded+21
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/email/email_validate_controller.goAdded+24
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/options/option_category_controller.goAdded+19
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/options/option_value_controller.goAdded+19
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/city/city_list_controller.goAdded+21
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/city/city_seeds_controller.goAdded+17
- space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/province/province_list_controller.goAdded+17
23 unmodified lines24252627282923 unmodified lines}ForgotPasswordController.RequestJSON(c, func() {ForgotPasswordController.Service.Constructor.Token = ForgotPasswordController.Request.TokenForgotPassword.Validate(ForgotPasswordController.Request.NewPassword)})}23 unmodified lines24252627282923 unmodified lines}ForgotPasswordController.RequestJSON(c, func() {ForgotPasswordController.Service.Constructor.Token = ForgotPasswordController.Request.TokenForgotPassword.Validate(&ForgotPasswordController.Request.NewPassword)})}
37 unmodified lines383940414237 unmodified lines}type ValidateForgotPasswordRequest struct {Token uint `json:"token" binding:"required"`NewPassword string `json:"new_password" binding:"required"`}37 unmodified lines383940414237 unmodified lines}type ValidateForgotPasswordRequest struct {Token uint `json:"token" binding:"required"`NewPassword string `json:"new_password"`}
29 unmodified lines30313229 unmodified linesAccount Account `json:"account"`Details AccountDetails `json:"details"`}29 unmodified lines3031323334353637383940414229 unmodified linesAccount Account `json:"account"`Details AccountDetails `json:"details"`}type AkademiDasar struct {Academies Academy `json:"academy"`Materials []AcademyMaterial `json:"academy_material"`Contents []AcademyContent `json:"academy_content"`}type AkademiDasarResponse struct {AkademiDasar []AkademiDasar `json:"academy_dasar"`}
69 unmodified lines7071727374757614 unmodified lines919293949596973 unmodified lines10110210310410569 unmodified lines// s.Result.Token = 0}func (s *ForgotPasswordService) Validate(newPassword string) {accountRepo := repositories.GetAccountById(s.Constructor.AccountID)if accountRepo.NoRecord {s.Error = accountRepo.RowsError14 unmodified liness.Exception.Message = "Token has expired!"return}hashed_password, _ := HashPassword(newPassword)accountRepo.Result.Password = hashed_passwordchangePassword := repositories.UpdateAccount(accountRepo.Result)if changePassword.RowsError != nil {3 unmodified linesreturn}// fgPasswordRepo.Result.Token = 0s.Result = fgPasswordRepo.Result}69 unmodified lines7071727374757614 unmodified lines9192939495969798991001013 unmodified lines10510610710810969 unmodified lines// s.Result.Token = 0}func (s *ForgotPasswordService) Validate(newPassword *string) {accountRepo := repositories.GetAccountById(s.Constructor.AccountID)if accountRepo.NoRecord {s.Error = accountRepo.RowsError14 unmodified liness.Exception.Message = "Token has expired!"return}s.Result = fgPasswordRepo.Resultif newPassword == nil {return}hashed_password, _ := HashPassword(*newPassword)accountRepo.Result.Password = hashed_passwordchangePassword := repositories.UpdateAccount(accountRepo.Result)if changePassword.RowsError != nil {3 unmodified linesreturn}// fgPasswordRepo.Result.Token = 0}
13 unmodified lines1415161718192013 unmodified linesGoogleLogin := services.GoogleAuthService{}ExternalAuthController.Service = &GoogleLogin.ServiceExternalAuthController.Service.Constructor.OauthID = ExternalAuthController.Request.OauthIDGoogleLogin.Authenticate()}})}13 unmodified lines1415161718192013 unmodified linesGoogleLogin := services.GoogleAuthService{}ExternalAuthController.Service = &GoogleLogin.ServiceExternalAuthController.Service.Constructor.OauthID = ExternalAuthController.Request.OauthIDGoogleLogin.Authenticate(ExternalAuthController.Request.IsAgreeTerms && !ExternalAuthController.Request.IsSexualDisease)}})}
1package auth1234567891011121314151617181920212223242526272829package authimport ("api.qobiltu.id/controller""api.qobiltu.id/models""api.qobiltu.id/services""github.com/gin-gonic/gin")func CreateForgotPassword(c *gin.Context) {ForgotPassword := services.ForgotPasswordService{}ForgotPasswordController := controller.Controller[models.ForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{Service: &ForgotPassword.Service,}ForgotPasswordController.RequestJSON(c, func() {ForgotPassword.Create(ForgotPasswordController.Request.Email)})}func ValidateForgotPassword(c *gin.Context) {ForgotPassword := services.ForgotPasswordService{}ForgotPasswordController := controller.Controller[models.ValidateForgotPasswordRequest, models.ForgotPassword, models.ForgotPassword]{Service: &ForgotPassword.Service,}ForgotPasswordController.RequestJSON(c, func() {ForgotPasswordController.Service.Constructor.Token = ForgotPasswordController.Request.TokenForgotPassword.Validate(&ForgotPasswordController.Request.NewPassword)})}
15 unmodified lines1617181920212215 unmodified linesemailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)emailVerificationController.RequestJSON(c, func() {emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.TokenemailVerificationController.Service.Constructor.UUID = emailVerificationController.Request.UUIDemailVerification.Validate()})})15 unmodified lines16171819202115 unmodified linesemailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)emailVerificationController.RequestJSON(c, func() {emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.TokenemailVerification.Validate()})})
123456712 unmodified lines20212223242526277 unmodified lines353637package modelsimport uuid "github.com/satori/go.uuid"type LoginRequest struct {Email string `json:"email" binding:"required"`Password string `json:"password" binding:"required"`12 unmodified lines}type CreateVerifyEmailRequest struct {Token uint `json:"token" binding:"required"`UUID uuid.UUID `json:"uuid" binding:"required"`}type OptionsRequest struct {7 unmodified linesIsAgreeTerms bool `json:"is_agree_terms"`IsSexualDisease bool `json:"is_sexual_disease"`}1234512 unmodified lines181920212223247 unmodified lines3233343536373839404142package modelstype LoginRequest struct {Email string `json:"email" binding:"required"`Password string `json:"password" binding:"required"`12 unmodified lines}type CreateVerifyEmailRequest struct {Token uint `json:"token" binding:"required"`}type OptionsRequest struct {7 unmodified linesIsAgreeTerms bool `json:"is_agree_terms"`IsSexualDisease bool `json:"is_sexual_disease"`}type ForgotPasswordRequest struct {Email string `json:"email" binding:"required,email"`}type ValidateForgotPasswordRequest struct {Token uint `json:"token" binding:"required"`NewPassword string `json:"new_password" binding:"required"`}
38 unmodified lines3940414243444546474838 unmodified linesrepo := Construct[models.Account, models.Account](account,)repo.Transactions(WhereGivenConstructor[models.Account, models.Account],Update[models.Account],)return *repo}38 unmodified lines394041424344454638 unmodified linesrepo := Construct[models.Account, models.Account](account,)repo.Transaction.Save(&repo.Constructor)repo.Result = repo.Constructorreturn *repo}
12 unmodified lines131415161712 unmodified linesrouterGroup.POST("/login", AuthController.Login)routerGroup.POST("/register", AuthController.Register)routerGroup.PUT("/change-password", middleware.AuthUser, AuthController.ChangePassword)}}12 unmodified lines1314151617181912 unmodified linesrouterGroup.POST("/login", AuthController.Login)routerGroup.POST("/register", AuthController.Register)routerGroup.PUT("/change-password", middleware.AuthUser, AuthController.ChangePassword)routerGroup.POST("/forgot-password", AuthController.CreateForgotPassword)routerGroup.PUT("/forgot-password", AuthController.ValidateForgotPassword)}}
57 unmodified lines5859606162636457 unmodified liness.Exception.Message = "incorrect old password!"return}accountData.Result.Password = newPasswordchangePassword := repositories.UpdateAccount(accountData.Result)changePassword.Result.Password = "SECRET"s.Result = models.AuthenticatedUser{57 unmodified lines585960616263646557 unmodified liness.Exception.Message = "incorrect old password!"return}hashed_password, _ := HashPassword(newPassword)accountData.Result.Password = hashed_passwordchangePassword := repositories.UpdateAccount(accountData.Result)changePassword.Result.Password = "SECRET"s.Result = models.AuthenticatedUser{
60 unmodified lines61626364656613 unmodified lines808182838485868760 unmodified linesreturn}}(accountRepo.Result.Email, token)}func (s *EmailVerificationService) Validate() {13 unmodified liness.Delete()return}s.Result = repo.Results.Delete()}func (s *EmailVerificationService) Delete() {60 unmodified lines6162636465666713 unmodified lines818283848586878889909160 unmodified linesreturn}}(accountRepo.Result.Email, token)// s.Result.Token = 0}func (s *EmailVerificationService) Validate() {13 unmodified liness.Delete()return}account := repositories.GetAccountById(repo.Result.AccountID)account.Result.IsEmailVerified = truerepositories.UpdateAccount(account.Result)s.Result = repo.Result}func (s *EmailVerificationService) Delete() {
13 unmodified lines141516171819204 unmodified lines25262728293013 unmodified linesService[models.ExternalAuth, models.AuthenticatedUser]}func (s *GoogleAuthService) Authenticate() {GoogleAuth := repositories.GetExternalAccountByOauthId(s.Constructor.OauthID)payload, errGoogleAuth := idtoken.Validate(context.Background(), s.Constructor.OauthID, "")s.Error = errGoogleAuth4 unmodified lines}email := payload.Claims["email"]if GoogleAuth.NoRecord {s.Constructor.UUID = uuid.NewV4()s.Constructor.OauthProvider = "Google"createAccount := repositories.CreateAccount(models.Account{13 unmodified lines141516171819204 unmodified lines252627282930313233343513 unmodified linesService[models.ExternalAuth, models.AuthenticatedUser]}func (s *GoogleAuthService) Authenticate(isAgree bool) {GoogleAuth := repositories.GetExternalAccountByOauthId(s.Constructor.OauthID)payload, errGoogleAuth := idtoken.Validate(context.Background(), s.Constructor.OauthID, "")s.Error = errGoogleAuth4 unmodified lines}email := payload.Claims["email"]if GoogleAuth.NoRecord {if !isAgree {s.Exception.BadRequest = trues.Exception.Message = "Please agree to the terms and conditions to create an account"return}s.Constructor.UUID = uuid.NewV4()s.Constructor.OauthProvider = "Google"createAccount := repositories.CreateAccount(models.Account{
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105package services
import (
"fmt"
"log"
"math/rand/v2"
"net/smtp"
"time"
"api.qobiltu.id/config"
"api.qobiltu.id/models"
"api.qobiltu.id/repositories"
uuid "github.com/satori/go.uuid"
)
type ForgotPasswordService struct {
Service[models.ForgotPassword, models.ForgotPassword]
}
func (s *ForgotPasswordService) Create(email string) {
if email == "" {
s.Exception.BadRequest = true
s.Exception.Message = "Email is required!"
return
}
accountRepo := repositories.GetAccountbyEmail(email)
if accountRepo.NoRecord {
s.Error = accountRepo.RowsError
s.Exception.DataNotFound = true
s.Exception.Message = "There is no account data with given credentials!"
return
}
remainingTime := time.Duration(config.EMAIL_VERIFICATION_DURATION) * time.Hour
dueTime := CalculateDueTime(remainingTime)
token := uint(rand.IntN(100000))
s.Constructor.UUID = uuid.NewV4()
s.Constructor.ExpiredAt = dueTime
s.Constructor.AccountID = accountRepo.Result.Id
s.Constructor.Token = token
repo := repositories.CreateForgotPassword(s.Constructor)
s.Error = repo.RowsError
s.Result = repo.Result
// ⬇ Kirim token ke email user menggunakan SMTP
go func(toEmail string, token uint) {
from := config.SMTP_SENDER_EMAIL
password := config.SMTP_SENDER_PASSWORD
smtpHost := config.SMTP_HOST
smtpPort := config.SMTP_PORT
auth := smtp.PlainAuth("", from, password, smtpHost)
subject := "Forgot Password Token"
body := fmt.Sprintf("Your Forgot Password token is: %06d\nPlease use it before it expires.", token)
msg := []byte("To: " + toEmail + "\r\n" +
"Subject: " + subject + "\r\n" +
"\r\n" +
body + "\r\n")
err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)
if err != nil {
s.Error = err
log.Printf("Error sending verification email: %v", err)
return
}
}(accountRepo.Result.Email, token)
// s.Result.Token = 0
}
func (s *ForgotPasswordService) Validate(newPassword string) {
accountRepo := repositories.GetAccountById(s.Constructor.AccountID)
if accountRepo.NoRecord {
s.Error = accountRepo.RowsError
s.Exception.DataNotFound = true
s.Exception.Message = "There is no account data with given credentials!"
return
}
fgPasswordRepo := repositories.GetForgotPasswordByToken(s.Constructor.Token)
s.Error = fgPasswordRepo.RowsError
if fgPasswordRepo.NoRecord {
s.Exception.DataNotFound = true
s.Exception.Message = "There is no forgot password data with given credentials!"
return
}
if fgPasswordRepo.Result.ExpiredAt.Before(time.Now()) {
s.Exception.Unauthorized = true
s.Exception.Message = "Token has expired!"
return
}
hashed_password, _ := HashPassword(newPassword)
accountRepo.Result.Password = hashed_password
changePassword := repositories.UpdateAccount(accountRepo.Result)
if changePassword.RowsError != nil {
s.Error = changePassword.RowsError
s.Exception.QueryError = true
s.Exception.Message = "Failed to update password!"
return
}
// fgPasswordRepo.Result.Token = 0
s.Result = fgPasswordRepo.Result
}68 unmodified lines6970717273743 unmodified lines78798081828384858687883 unmodified lines929394959697989968 unmodified linesAccount: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}}func (s *UserProfileService) Update() {3 unmodified lines}usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif *s.Constructor.Gender {initialName = "IKH_"} else {initialName = "AKH_"}initialName += strconv.Itoa(usersCount)s.Constructor.InitialName = initialNameuserProfile := repositories.UpdateAccountDetails(s.Constructor)3 unmodified liness.Exception.Message = "There is no account with given credentials!"return}s.Result = models.UserProfileResponse{Account: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"68 unmodified lines697071727374753 unmodified lines79808182838485868788899091923 unmodified lines9697989910010110210310410510610710810911011111211311468 unmodified linesAccount: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"}func (s *UserProfileService) Update() {3 unmodified lines}usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif s.Constructor.Gender != nil {if *s.Constructor.Gender {initialName = "IKH_"} else {initialName = "AKH_"}}initialName += strconv.Itoa(usersCount)s.Constructor.InitialName = initialNameuserProfile := repositories.UpdateAccountDetails(s.Constructor)3 unmodified liness.Exception.Message = "There is no account with given credentials!"return}account := repositories.GetAccountById(s.Constructor.AccountID)account.Result.IsDetailCompleted = (userProfile.Result.InitialName != "" &&userProfile.Result.FullName != nil &&userProfile.Result.DateOfBirth != nil &&userProfile.Result.PlaceOfBirth != nil &&userProfile.Result.Domicile != nil &&userProfile.Result.LastJob != nil &&userProfile.Result.Gender != nil &&userProfile.Result.LastEducation != nil &&userProfile.Result.MaritalStatus != nil)repositories.UpdateAccount(account.Result)s.Result = models.UserProfileResponse{Account: account.Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"
1234567835 unmodified lines4445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114package servicesimport ("crypto/tls""fmt""math/rand/v2""net/smtp""time"35 unmodified linessmtpHost := config.SMTP_HOSTsmtpPort := config.SMTP_PORTtlsconfig := &tls.Config{InsecureSkipVerify: true,ServerName: smtpHost,}conn, err := tls.Dial("tcp", fmt.Sprintf("%s:%d", smtpHost, smtpPort), tlsconfig)if err != nil {panic(err)}client, err := smtp.NewClient(conn, smtpHost)if err != nil {panic(err)}// auth := smtp.PlainAuth("", from, password, smtpHost)auth := smtp.PlainAuth("", from, password, smtpHost)if err = client.Auth(auth); err != nil {panic(err)}if err = client.Mail(from); err != nil {panic(err)}to := []string{toEmail}for _, addr := range to {if err = client.Rcpt(addr); err != nil {panic(err)}}wc, err := client.Data()if err != nil {panic(err)}msg := []byte("Subject: Test Email\r\n\r\nThis is the email body.")_, err = wc.Write(msg)if err != nil {panic(err)}err = wc.Close()if err != nil {panic(err)}client.Quit()fmt.Println("Email sent successfully!")// subject := "Email Verification Token"// body := fmt.Sprintf("Your verification token is: %06d\nPlease use it before it expires.", token)// msg := []byte("To: " + toEmail + "\r\n" +// "Subject: " + subject + "\r\n" +// "\r\n" +// body + "\r\n")// err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)// if err != nil {// s.Error = err// log.Printf("Error sending verification email: %v", err)// return// }}(accountRepo.Result.Email, token)}1234567835 unmodified lines44454647484950515253545556575859606162636465package servicesimport ("fmt""log""math/rand/v2""net/smtp""time"35 unmodified linessmtpHost := config.SMTP_HOSTsmtpPort := config.SMTP_PORTauth := smtp.PlainAuth("", from, password, smtpHost)subject := "Email Verification Token"body := fmt.Sprintf("Your verification token is: %06d\nPlease use it before it expires.", token)msg := []byte("To: " + toEmail + "\r\n" +"Subject: " + subject + "\r\n" +"\r\n" +body + "\r\n")err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)if err != nil {s.Error = errlog.Printf("Error sending verification email: %v", err)return}}(accountRepo.Result.Email, token)}
1234567835 unmodified lines44454647484950515253545556575859606162636465package servicesimport ("fmt""log""math/rand/v2""net/smtp""time"35 unmodified linessmtpHost := config.SMTP_HOSTsmtpPort := config.SMTP_PORTauth := smtp.PlainAuth("", from, password, smtpHost)subject := "Email Verification Token"body := fmt.Sprintf("Your verification token is: %06d\nPlease use it before it expires.", token)msg := []byte("To: " + toEmail + "\r\n" +"Subject: " + subject + "\r\n" +"\r\n" +body + "\r\n")err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)if err != nil {s.Error = errlog.Printf("Error sending verification email: %v", err)return}}(accountRepo.Result.Email, token)}1234567835 unmodified lines4445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114package servicesimport ("crypto/tls""fmt""math/rand/v2""net/smtp""time"35 unmodified linessmtpHost := config.SMTP_HOSTsmtpPort := config.SMTP_PORTtlsconfig := &tls.Config{InsecureSkipVerify: true,ServerName: smtpHost,}conn, err := tls.Dial("tcp", fmt.Sprintf("%s:%d", smtpHost, smtpPort), tlsconfig)if err != nil {panic(err)}client, err := smtp.NewClient(conn, smtpHost)if err != nil {panic(err)}// auth := smtp.PlainAuth("", from, password, smtpHost)auth := smtp.PlainAuth("", from, password, smtpHost)if err = client.Auth(auth); err != nil {panic(err)}if err = client.Mail(from); err != nil {panic(err)}to := []string{toEmail}for _, addr := range to {if err = client.Rcpt(addr); err != nil {panic(err)}}wc, err := client.Data()if err != nil {panic(err)}msg := []byte("Subject: Test Email\r\n\r\nThis is the email body.")_, err = wc.Write(msg)if err != nil {panic(err)}err = wc.Close()if err != nil {panic(err)}client.Quit()fmt.Println("Email sent successfully!")// subject := "Email Verification Token"// body := fmt.Sprintf("Your verification token is: %06d\nPlease use it before it expires.", token)// msg := []byte("To: " + toEmail + "\r\n" +// "Subject: " + subject + "\r\n" +// "\r\n" +// body + "\r\n")// err := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)// if err != nil {// s.Error = err// log.Printf("Error sending verification email: %v", err)// return// }}(accountRepo.Result.Email, token)}
1 unmodified line23456774 unmodified lines828384858687881 unmodified lineimport ("regexp""strings""api.qobiltu.id/models"74 unmodified lines} else {initialName = "AKH_"}initialName += string(usersCount)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified line234567874 unmodified lines83848586878889901 unmodified lineimport ("regexp""strconv""strings""api.qobiltu.id/models"74 unmodified lines} else {initialName = "AKH_"}initialName += strconv.Itoa(usersCount)s.Constructor.InitialName = initialNameuserProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {
29 unmodified lines30313233343529 unmodified lines}type ExternalAuthRequest struct {OauthID string `json:"oauth_id" binding:"required"`OauthProvider string `json:"oauth_provider" binding:"required"`}29 unmodified lines303132333435363729 unmodified lines}type ExternalAuthRequest struct {OauthID string `json:"oauth_id" binding:"required"`OauthProvider string `json:"oauth_provider" binding:"required"`IsAgreeTerms bool `json:"is_agree_terms"`IsSexualDisease bool `json:"is_sexual_disease"`}
17 unmodified lines1819202122234 unmodified lines28293031323317 unmodified liness.Exception.Message = "there is no account with given credentials!"return}if VerifyPassword(accountData.Result.Password, s.Constructor.Password) != nil {s.Exception.Unauthorized = trues.Exception.Message = "incorrect password!"4 unmodified linesif err_tok != nil {s.Error = errors.Join(s.Error, err_tok)}accountData.Result.Password = "SECRET"17 unmodified lines181920212223244 unmodified lines2930313233343517 unmodified liness.Exception.Message = "there is no account with given credentials!"return}if VerifyPassword(accountData.Result.Password, s.Constructor.Password) != nil {s.Exception.Unauthorized = trues.Exception.Message = "incorrect password!"4 unmodified linesif err_tok != nil {s.Error = errors.Join(s.Error, err_tok)return}accountData.Result.Password = "SECRET"
55 unmodified lines5657585960616212 unmodified lines75767778798081828355 unmodified lineserr := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)if err != nil {log.Printf("Error sending verification email: %v", err)}}(accountRepo.Result.Email, token)}12 unmodified liness.Exception.Unauthorized = trues.Exception.Message = "Token has expired!"repositories.UpdateExpiredEmailVerification(s.Constructor.UUID)return}s.Result = repo.Result}func (s *EmailVerificationService) Delete() {55 unmodified lines56575859606162636412 unmodified lines777879808182838485868755 unmodified lineserr := smtp.SendMail(smtpHost+":"+smtpPort, auth, from, []string{toEmail}, msg)if err != nil {s.Error = errlog.Printf("Error sending verification email: %v", err)return}}(accountRepo.Result.Email, token)}12 unmodified liness.Exception.Unauthorized = trues.Exception.Message = "Token has expired!"repositories.UpdateExpiredEmailVerification(s.Constructor.UUID)s.Delete()return}s.Result = repo.Results.Delete()}func (s *EmailVerificationService) Delete() {
70 unmodified lines717273747576777813 unmodified lines9293949570 unmodified lines}func (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif *s.Constructor.Gender {13 unmodified linesAccount: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}}70 unmodified lines7172737475767778798013 unmodified lines949596979870 unmodified lines}func (s *UserProfileService) Update() {if s.Constructor.PhoneNumber != nil {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)}usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif *s.Constructor.Gender {13 unmodified linesAccount: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}s.Result.Account.Password = "SECRET"}
14 unmodified lines15161718192014 unmodified linesreturn *repo}func GetAccountById(accountId uint) Repository[models.Account, models.Account] {repo := Construct[models.Account, models.Account](models.Account{Id: accountId},14 unmodified lines15161718192021222324252627282914 unmodified linesreturn *repo}func GetAllAccount() Repository[models.Account, []models.Account] {repo := Construct[models.Account, []models.Account](models.Account{},)repo.Transactions(Find[models.Account, []models.Account],)return *repo}func GetAccountById(accountId uint) Repository[models.Account, models.Account] {repo := Construct[models.Account, models.Account](models.Account{Id: accountId},
32 unmodified lines3334353637383932 unmodified lines})s.Constructor.AccountID = createAccount.Result.IdcreateGoogleAuth := repositories.CreateExternalAuth(s.Constructor)s.Error = createGoogleAuth.RowsErrors.Error = errors.Join(s.Error, createAccount.RowsError)}32 unmodified lines3334353637383932 unmodified lines})s.Constructor.AccountID = createAccount.Result.IdcreateGoogleAuth := repositories.CreateExternalAuth(s.Constructor)GoogleAuth.Result.AccountID = createGoogleAuth.Result.IDs.Error = createGoogleAuth.RowsErrors.Error = errors.Join(s.Error, createAccount.RowsError)}
72 unmodified lines73747576777872 unmodified linesfunc (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {72 unmodified lines737475767778798081828384858672 unmodified linesfunc (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif *s.Constructor.Gender {initialName = "IKH_"} else {initialName = "AKH_"}initialName += string(usersCount)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {
43 unmodified lines444546474849505123 unmodified lines75767778798043 unmodified linesreturn input}func (s *UserProfileService) Create() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)userProfile := repositories.CreateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {23 unmodified linesfunc (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {43 unmodified lines44454647484923 unmodified lines737475767778798081828384858643 unmodified linesreturn input}func (s *UserProfileService) Create() {userProfile := repositories.CreateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {23 unmodified linesfunc (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)usersCount := repositories.GetAllAccount().RowsCountvar initialName stringif *s.Constructor.Gender {initialName = "IKH_"} else {initialName = "AKH_"}initialName += string(usersCount)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {
23 unmodified lines2425262728293023 unmodified linesports:- "5432:5432"volumes:- db-data:/var/lib/postgresql/datarestart: alwaysvolumes:23 unmodified lines2425262728293023 unmodified linesports:- "5432:5432"volumes:- /home/qobiltu/postgres-data:/var/lib/postgresql/datarestart: alwaysvolumes:
27 unmodified lines28293031323327 unmodified lines# Copy hasil build dari builder ke image runtimeCOPY --from=builder /app/main .# Copy file .env untuk konfigurasi environmentCOPY .env .env27 unmodified lines28293031323334353627 unmodified lines# Copy hasil build dari builder ke image runtimeCOPY --from=builder /app/main .# Copy folder utils (termasuk file seeder) dari builder ke runtimeCOPY --from=builder /app/utils ./utils# Copy file .env untuk konfigurasi environmentCOPY .env .env
8 unmodified lines91011121314158 unmodified linesfunc Profile(c *gin.Context) {userProfile := services.UserProfileService{}userProfileController := controller.Controller[any, models.AccountDetails, models.AccountDetails]{Service: &userProfile.Service,}userProfileController.HeaderParse(c, func() {8 unmodified lines91011121314158 unmodified linesfunc Profile(c *gin.Context) {userProfile := services.UserProfileService{}userProfileController := controller.Controller[any, models.AccountDetails, models.UserProfileResponse]{Service: &userProfile.Service,}userProfileController.HeaderParse(c, func() {
123456782 unmodified lines111213141516171 unmodified line19202122232425package userimport ("fmt""api.qobiltu.id/controller""api.qobiltu.id/models""api.qobiltu.id/services"2 unmodified linesfunc UpdateProfile(c *gin.Context) {userProfile := services.UserProfileService{}userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.AccountDetails]{Service: &userProfile.Service,}1 unmodified lineuserUpdateProfileController.Service.Constructor = userUpdateProfileController.RequestuserUpdateProfileController.HeaderParse(c, func() {userUpdateProfileController.Service.Constructor.AccountID = uint(userUpdateProfileController.AccountData.UserID)fmt.Println("Account ID:", userUpdateProfileController.Service.Constructor.AccountID)})userProfile.Update()},1234562 unmodified lines91011121314151 unmodified line17181920212223package userimport ("api.qobiltu.id/controller""api.qobiltu.id/models""api.qobiltu.id/services"2 unmodified linesfunc UpdateProfile(c *gin.Context) {userProfile := services.UserProfileService{}userUpdateProfileController := controller.Controller[models.AccountDetails, models.AccountDetails, models.UserProfileResponse]{Service: &userProfile.Service,}1 unmodified lineuserUpdateProfileController.Service.Constructor = userUpdateProfileController.RequestuserUpdateProfileController.HeaderParse(c, func() {userUpdateProfileController.Service.Constructor.AccountID = uint(userUpdateProfileController.AccountData.UserID)})userProfile.Update()},
1
2 unmodified lines3456789106 unmodified lines171819202122232 unmodified linespackage middlewareimport ("fmt""api.qobiltu.id/models""api.qobiltu.id/services""api.qobiltu.id/utils"6 unmodified linestoken := c.Request.Header["Authorization"]currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])fmt.Println(token[0])if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {currAccData.UserID = 02 unmodified lines3456786 unmodified lines1516171819202 unmodified linespackage middlewareimport ("api.qobiltu.id/models""api.qobiltu.id/services""api.qobiltu.id/utils"6 unmodified linestoken := c.Request.Header["Authorization"]currAccData.UserID, currAccData.VerifyStatus, currAccData.ErrVerif = services.VerifyToken(token[0])if currAccData.VerifyStatus == "invalid-token" || currAccData.VerifyStatus == "expired" {currAccData.UserID = 0
24 unmodified lines25262724 unmodified linestype OptionsResponse struct {Options []Options `json:"options"`}24 unmodified lines252627282930313224 unmodified linestype OptionsResponse struct {Options []Options `json:"options"`}type UserProfileResponse struct {Account Account `json:"account"`Details AccountDetails `json:"details"`}
1234567855 unmodified lines6465666768697071package repositoriesimport ("fmt""api.qobiltu.id/models")55 unmodified linesrepo := Construct[models.AccountDetails, models.AccountDetails](accountDetails,)fmt.Println(accountDetails)fmt.Println("Account ID : ", accountDetails.AccountID)Create(repo)return *repo}12345655 unmodified lines626364656667package repositoriesimport ("api.qobiltu.id/models")55 unmodified linesrepo := Construct[models.AccountDetails, models.AccountDetails](accountDetails,)Create(repo)return *repo}
12345678910111213141516171819202122package repositories
import "api.qobiltu.id/models"
func CreateForgotPassword(forgotPassword models.ForgotPassword) Repository[models.ForgotPassword, models.ForgotPassword] {
repo := Construct[models.ForgotPassword, models.ForgotPassword](
forgotPassword,
)
Create(repo)
return *repo
}
func GetForgotPasswordByToken(token uint) Repository[models.ForgotPassword, models.ForgotPassword] {
repo := Construct[models.ForgotPassword, models.ForgotPassword](
models.ForgotPassword{Token: token},
)
repo.Transactions(
WhereGivenConstructor[models.ForgotPassword, models.ForgotPassword],
Find[models.ForgotPassword, models.ForgotPassword],
)
return *repo
}1234562 unmodified lines91011121314151617package routerimport ("api.qobiltu.id/config""api.qobiltu.id/controller""github.com/gin-gonic/gin"2 unmodified linesfunc StartService() {router := gin.Default()router.GET("/", controller.HomeController)AuthRoute(router)UserRoute(router)EmailRoute(router)OptionsRoute(router)router.Run(config.TCP_ADDRESS)}123456782 unmodified lines1112131415161718192021222324package routerimport ("log""api.qobiltu.id/config""api.qobiltu.id/controller""github.com/gin-gonic/gin"2 unmodified linesfunc StartService() {router := gin.Default()router.GET("/", controller.HomeController)AuthRoute(router)UserRoute(router)EmailRoute(router)OptionsRoute(router)err := router.Run(config.TCP_ADDRESS)if err != nil {log.Fatalf("Failed to run server: %v", err)}}
26 unmodified lines27282930313233343536373839404126 unmodified linesif GoogleAuth.NoRecord {s.Constructor.UUID = uuid.NewV4()s.Constructor.OauthProvider = "Google"createGoogleAuth := repositories.CreateExternalAuth(s.Constructor)s.Error = createGoogleAuth.RowsErrorcreateAccount := repositories.CreateAccount(models.Account{Email: email.(string),IsEmailVerified: true,})s.Error = errors.Join(s.Error, createAccount.RowsError)}accountData := repositories.GetAccountById(GoogleAuth.Result.AccountID)26 unmodified lines272829303132333435363738394026 unmodified linesif GoogleAuth.NoRecord {s.Constructor.UUID = uuid.NewV4()s.Constructor.OauthProvider = "Google"createAccount := repositories.CreateAccount(models.Account{Email: email.(string),IsEmailVerified: true,})s.Constructor.AccountID = createAccount.Result.IdcreateGoogleAuth := repositories.CreateExternalAuth(s.Constructor)s.Error = createGoogleAuth.RowsErrors.Error = errors.Join(s.Error, createAccount.RowsError)}accountData := repositories.GetAccountById(GoogleAuth.Result.AccountID)
12345678910111213141516171 unmodified line192021222324253 unmodified lines29303132333435363738391 unmodified line4142434445package servicesimport ("fmt""api.qobiltu.id/models""api.qobiltu.id/repositories")type UserProfileService struct {Service[models.AccountDetails, models.AccountDetails]}func (s *UserProfileService) Create() {userProfile := repositories.CreateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}s.Result = userProfile.Result}func (s *UserProfileService) Retrieve() {userProfile := repositories.GetDetailAccountById(s.Constructor.AccountID)3 unmodified liness.Exception.Message = "There is no account with given credentials!"return}s.Result = userProfile.Result}func (s *UserProfileService) Update() {fmt.Println("Account ID:", s.Constructor.AccountID)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}s.Result = userProfile.Result}1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950511 unmodified line535455565758596061623 unmodified lines6667686970717273747576777879801 unmodified line8283848586878889package servicesimport ("regexp""strings""api.qobiltu.id/models""api.qobiltu.id/repositories")type UserProfileService struct {Service[models.AccountDetails, models.UserProfileResponse]}// SanitizePhoneNumber membersihkan dan menormalkan nomor telepon ke format +62func SanitizePhoneNumber(input string) string {// Hilangkan semua spasi dan stripinput = strings.ReplaceAll(input, " ", "")input = strings.ReplaceAll(input, "-", "")input = strings.ReplaceAll(input, "(", "")input = strings.ReplaceAll(input, ")", "")// Hilangkan semua karakter non-digit kecuali +re := regexp.MustCompile(`[^0-9\+]`)input = re.ReplaceAllString(input, "")// Handle nomor diawali 0 (contoh: 0812...) menjadi +62812...if strings.HasPrefix(input, "0") {input = "+62" + input[1:]}// Handle jika diawali dengan 62 tanpa + (contoh: 62812...)if strings.HasPrefix(input, "62") && !strings.HasPrefix(input, "+62") {input = "+" + input}// Handle jika tidak ada awalan +62 sama sekali (contoh: 8123456789)if !strings.HasPrefix(input, "+62") {if strings.HasPrefix(input, "8") {input = "+62" + input}}return input}func (s *UserProfileService) Create() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)userProfile := repositories.CreateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}s.Result = models.UserProfileResponse{Account: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}}func (s *UserProfileService) Retrieve() {userProfile := repositories.GetDetailAccountById(s.Constructor.AccountID)3 unmodified liness.Exception.Message = "There is no account with given credentials!"return}s.Result = models.UserProfileResponse{Account: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}}func (s *UserProfileService) Update() {phoneNumber := *s.Constructor.PhoneNumber*s.Constructor.PhoneNumber = SanitizePhoneNumber(phoneNumber)userProfile := repositories.UpdateAccountDetails(s.Constructor)s.Error = userProfile.RowsErrorif userProfile.NoRecord {1 unmodified lines.Exception.Message = "There is no account with given credentials!"return}s.Result = models.UserProfileResponse{Account: repositories.GetAccountById(s.Constructor.AccountID).Result,Details: userProfile.Result,}}
12345.envvendor/quzuu-be.exeREADME.md.qodo1234567.envvendor/quzuu-be.exeREADME.md.qodo.errorlogs/
8 unmodified lines91011121314151617181 unmodified line20212223248 unmodified linesvar TCP_ADDRESS stringvar LOG_PATH stringvar HOST_ADDRESS stringvar HOST_PORT stringvar EMAIL_VERIFICATION_DURATION intfunc init() {godotenv.Load()HOST_ADDRESS = os.Getenv("HOST_ADDRESS")1 unmodified lineTCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORTLOG_PATH = os.Getenv("LOG_PATH")EMAIL_VERIFICATION_DURATION, _ = strconv.Atoi(os.Getenv("EMAIL_VERIFICATION_DURATION"))// Menampilkan nilai variabel lingkungan}8 unmodified lines91011121314151617181920212223241 unmodified line2627282930313233348 unmodified linesvar TCP_ADDRESS stringvar LOG_PATH stringvar HOST_ADDRESS stringvar HOST_PORT stringvar EMAIL_VERIFICATION_DURATION intvar SMTP_SENDER_EMAIL stringvar SMTP_SENDER_PASSWORD stringvar SMTP_HOST stringvar SMTP_PORT stringfunc init() {godotenv.Load()HOST_ADDRESS = os.Getenv("HOST_ADDRESS")1 unmodified lineTCP_ADDRESS = HOST_ADDRESS + ":" + HOST_PORTLOG_PATH = os.Getenv("LOG_PATH")EMAIL_VERIFICATION_DURATION, _ = strconv.Atoi(os.Getenv("EMAIL_VERIFICATION_DURATION"))SMTP_SENDER_EMAIL = os.Getenv("SMTP_SENDER_EMAIL")SMTP_SENDER_PASSWORD = os.Getenv("SMTP_SENDER_PASSWORD")SMTP_HOST = os.Getenv("SMTP_HOST")SMTP_PORT = os.Getenv("SMTP_PORT")// Menampilkan nilai variabel lingkungan}
59 unmodified lines60616263646559 unmodified lines&models.AcademyContent{},&models.AcademyMaterialProgress{},&models.AcademyContentProgress{},)if err != nil {59 unmodified lines6061626364656667686959 unmodified lines&models.AcademyContent{},&models.AcademyMaterialProgress{},&models.AcademyContentProgress{},&models.RegionCity{},&models.RegionProvince{},&models.OptionCategory{},&models.OptionValues{},)if err != nil {
1234567891011121314151617181920package auth
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func ExternalAuth(c *gin.Context) {
ExternalAuthController := controller.Controller[models.ExternalAuthRequest, models.ExternalAuth, models.AuthenticatedUser]{}
ExternalAuthController.RequestJSON(c, func() {
if ExternalAuthController.Request.OauthProvider == "google" {
GoogleLogin := services.GoogleAuthService{}
ExternalAuthController.Service = &GoogleLogin.Service
ExternalAuthController.Service.Constructor.OauthID = ExternalAuthController.Request.OauthID
GoogleLogin.Authenticate()
}
})
}1package auth123456789101112131415161718192021package controller
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func CreateVerification(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.CreateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.HeaderParse(c, func() {
emailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)
emailVerification.Create()
emailVerificationController.Response(c)
})
}123456789101112131415161718192021222324package controller
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Verify(c *gin.Context) {
emailVerification := services.EmailVerificationService{}
emailVerificationController := controller.Controller[models.CreateVerifyEmailRequest, models.EmailVerification, models.EmailVerification]{
Service: &emailVerification.Service,
}
emailVerificationController.HeaderParse(c, func() {
emailVerificationController.Service.Constructor.AccountID = uint(emailVerificationController.AccountData.UserID)
emailVerificationController.RequestJSON(c, func() {
emailVerificationController.Service.Constructor.Token = emailVerificationController.Request.Token
emailVerificationController.Service.Constructor.UUID = emailVerificationController.Request.UUID
emailVerification.Validate()
})
})
}12345678910111213141516171819package options
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func AddOptions(c *gin.Context) {
options := services.OptionService{}
addOptionController := controller.Controller[[]models.OptionsRequest, []models.OptionsRequest, models.OptionsResponse]{
Service: &options.Service,
}
addOptionController.RequestJSON(c, func() {
options.Constructor = addOptionController.Request
options.Create()
})
}12345678910111213141516171819package options
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
options := services.OptionValueService{}
optionValueController := controller.Controller[any, models.OptionCategory, models.Options]{
Service: &options.Service,
}
slug := c.Param("slug")
options.Constructor.OptionSlug = slug
options.Retrieve()
optionValueController.Response(c)
}123456789101112131415161718192021package city
import (
"strconv"
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
city := services.CityService{}
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
Service: &city.Service,
}
ProvinceID, _ := strconv.Atoi(c.Query("province_id"))
city.Constructor.ProvinceID = uint(ProvinceID)
city.Retrieve()
CityController.Response(c)
}1234567891011121314151617package city
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func Seeds(c *gin.Context) {
city := services.CityService{}
CityController := controller.Controller[any, models.RegionCity, []models.RegionCity]{
Service: &city.Service,
}
city.Create()
CityController.Response(c)
}1234567891011121314151617package province
import (
"api.qobiltu.id/controller"
"api.qobiltu.id/models"
"api.qobiltu.id/services"
"github.com/gin-gonic/gin"
)
func List(c *gin.Context) {
province := services.ProvinceService{}
ProvinceController := controller.Controller[any, models.RegionProvince, []models.RegionProvince]{
Service: &province.Service,
}
province.Retrieve()
ProvinceController.Response(c)
}controller/auth/auth_forgot_password_controller.go+1-1
models/request_model.go+1-1
models/response_model.go+10
services/forgot_password_service.go+7-3
space/controller/auth/auth_external_controller.go+1-1
space/controller/auth/auth_forgot_password_controller.go+28
space/controller/email/email_validate_controller.go-1
space/models/request_model.go+9-4
space/repositories/account_repository.go+2-4
space/router/auth_route.go+2
space/services/authentication_service.go+2-1
space/services/email_verification_service.go+5-1
space/services/external_authentication_service.go+6-1
space/services/forgot_password_service.goAdded+105
space/services/user_profile_service.go+20-5
space/space/space/services/email_verification_service.go+11-60
space/space/space/space/space/services/email_verification_service.go+60-11
space/space/space/space/space/space/services/user_profile_service.go+3-1
space/space/space/space/space/space/space/models/request_model.go+4-2
space/space/space/space/space/space/space/services/authentication_service.go+2
space/space/space/space/space/space/space/services/email_verification_service.go+4
space/space/space/space/space/space/space/services/user_profile_service.go+5-2
space/space/space/space/space/space/space/space/repositories/account_repository.go+9
space/space/space/space/space/space/space/space/services/external_authentication_service.go+1-1
space/space/space/space/space/space/space/space/services/user_profile_service.go+8
space/space/space/space/space/space/space/space/space/services/user_profile_service.go+8-2
space/space/space/space/space/space/space/space/space/space/docker-compose.yml+1-1
space/space/space/space/space/space/space/space/space/space/space/space/Dockerfile+3
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/user/user_profile_controller.go+1-1
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/user/user_update_profile_controller.go+2-4
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/logs/error_log.txt+1
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/middleware/authentication_middleware.go-3
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/models/response_model.go+5
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/repositories/account_repository.go-4
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/repositories/forgot_password_repository.goAdded+22
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/router/router.go+8-1
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/services/external_authentication_service.go+4-5
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/services/user_profile_service.go+50-6
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/.gitignore+4-2
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/config/config.go+10
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/config/database_connection_config.go+4
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/auth/auth_external_controller.goAdded+20
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/auth/auth_forgot_password_controller.goAdded+1
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/email/email_create_verification_controller.goAdded+21
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/email/email_validate_controller.goAdded+24
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/options/option_category_controller.goAdded+19
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/options/option_value_controller.goAdded+19
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/city/city_list_controller.goAdded+21
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/city/city_seeds_controller.goAdded+17
space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/space/controller/region/province/province_list_controller.goAdded+17