2023-12-03 03:47:23 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/divyam234/teldrive/pkg/httputil"
|
2024-02-12 04:52:41 +08:00
|
|
|
"github.com/divyam234/teldrive/pkg/schemas"
|
2023-12-03 03:47:23 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (ac *Controller) GetSession(c *gin.Context) {
|
|
|
|
session := ac.AuthService.GetSession(c)
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, session)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ac *Controller) LogIn(c *gin.Context) {
|
2024-02-12 04:52:41 +08:00
|
|
|
|
|
|
|
var session schemas.TgSession
|
|
|
|
if err := c.ShouldBindJSON(&session); err != nil {
|
|
|
|
httputil.NewError(c, http.StatusBadRequest, err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
res, err := ac.AuthService.LogIn(c, &session)
|
2023-12-03 03:47:23 +08:00
|
|
|
if err != nil {
|
|
|
|
httputil.NewError(c, err.Code, err.Error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ac *Controller) Logout(c *gin.Context) {
|
|
|
|
res, err := ac.AuthService.Logout(c)
|
|
|
|
if err != nil {
|
|
|
|
httputil.NewError(c, err.Code, err.Error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
c.JSON(http.StatusOK, res)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (ac *Controller) HandleMultipleLogin(c *gin.Context) {
|
|
|
|
ac.AuthService.HandleMultipleLogin(c)
|
|
|
|
}
|