6 "github.com/gin-gonic/gin"
11 Handlers []gin.HandlerFunc
17 Middlewares []Middleware
26 {"POST", []gin.HandlerFunc{Signup}, "/signup"},
27 {"POST", []gin.HandlerFunc{Signin}, "/signin"},
32 []Middleware{JwtAuth, UserConfirmed},
34 {"GET", []gin.HandlerFunc{OtpEnrollment}, "/enroll"},
35 {"POST", []gin.HandlerFunc{OtpValidate}, "/validate"},
40 []Middleware{JwtAuth, UserConfirmed, OtpAuth},
42 {"GET", []gin.HandlerFunc{GetMarketConfig}, "/:name"},
43 {"POST", []gin.HandlerFunc{UpdateMarketConfig}, "/:name/update"},
48 func Signup(c *gin.Context) {
49 query := &SignupQuery{}
51 query.In.Email = c.PostForm("email")
52 query.In.Password = c.PostForm("password")
57 func Signin(c *gin.Context) {
58 query := &SigninQuery{}
60 query.In.Email = c.PostForm("email")
61 query.In.Password = c.PostForm("password")
66 func OtpValidate(c *gin.Context) {
67 query := &OtpValidateQuery{}
69 query.In.Pass = c.PostForm("pass")
70 query.In.User = GetUser(c)
71 query.In.Claims = GetClaims(c)
76 func OtpEnrollment(c *gin.Context) {
77 query := &OtpEnrollmentQuery{}
79 query.In.User = GetUser(c)
81 qrPng, secret, err := query.Run()
83 WriteJsonResponse(ErrorResponse(err.Code, err.UserMessage), c)
88 if c.Query("format") == "png" {
89 c.Header("X-OTP-Secret", secret)
90 WriteBinary("image/png", qrPng.Bytes(), c)
93 Base64img string `json:"base64img"`
94 OtpSecret string `json:"secret"`
96 base64.StdEncoding.EncodeToString(qrPng.Bytes()),
100 WriteJsonResponse(SuccessResponse(response), c)
105 func GetMarketConfig(c *gin.Context) {
106 query := &MarketConfigQuery{}
108 query.In.User = GetUser(c)
109 query.In.Market = c.Param("name")
114 func UpdateMarketConfig(c *gin.Context) {
115 query := &UpdateMarketConfigQuery{}
117 query.In.User = GetUser(c)
118 query.In.Market = c.Param("name")
119 query.In.Key = c.PostForm("key")
120 query.In.Secret = c.PostForm("secret")