MIF_E31222379_BE/internal/authentication/authentication_route.go

42 lines
1.3 KiB
Go

package authentication
import (
"rijig/config"
"rijig/internal/role"
"rijig/middleware"
"github.com/gofiber/fiber/v2"
)
func AuthenticationRouter(api fiber.Router) {
repoAuth := NewAuthenticationRepository(config.DB)
repoRole := role.NewRoleRepository(config.DB)
authService := NewAuthenticationService(repoAuth, repoRole)
authHandler := NewAuthenticationHandler(authService)
authRoute := api.Group("/auth")
authRoute.Post("/refresh-token",
middleware.AuthMiddleware(),
middleware.DeviceValidation(),
authHandler.RefreshToken,
)
// authRoute.Get("/me",
// middleware.AuthMiddleware(),
// middleware.CheckRefreshTokenTTL(30*time.Second),
// middleware.RequireApprovedRegistration(),
// authHandler.GetMe,
// )
authRoute.Get("/cekapproval", middleware.AuthMiddleware(), authHandler.GetRegistrationStatus)
authRoute.Post("/login/admin", authHandler.Login)
authRoute.Post("/register/admin", authHandler.Register)
authRoute.Post("/request-otp", authHandler.RequestOtpHandler)
authRoute.Post("/verif-otp", authHandler.VerifyOtpHandler)
authRoute.Post("/request-otp/register", authHandler.RequestOtpRegistHandler)
authRoute.Post("/verif-otp/register", authHandler.VerifyOtpRegistHandler)
authRoute.Post("/logout", middleware.AuthMiddleware(), authHandler.LogoutAuthentication)
}