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"},
44 {"GET", []gin.HandlerFunc{GetMarketBalance}, "/:name/balance"},
49 func Signup(c *gin.Context) {
50 query := &SignupQuery{}
52 query.In.Email = c.PostForm("email")
53 query.In.Password = c.PostForm("password")
58 func Signin(c *gin.Context) {
59 query := &SigninQuery{}
61 query.In.Email = c.PostForm("email")
62 query.In.Password = c.PostForm("password")
67 func OtpValidate(c *gin.Context) {
68 query := &OtpValidateQuery{}
70 query.In.Pass = c.PostForm("pass")
71 query.In.User = GetUser(c)
72 query.In.Claims = GetClaims(c)
77 func OtpEnrollment(c *gin.Context) {
78 query := &OtpEnrollmentQuery{}
80 query.In.User = GetUser(c)
82 qrPng, secret, err := query.Run()
84 WriteJsonResponse(ErrorResponse(err.Code, err.UserMessage), c)
89 if c.Query("format") == "png" {
90 c.Header("X-OTP-Secret", secret)
91 WriteBinary("image/png", qrPng.Bytes(), c)
94 Base64img string `json:"base64img"`
95 OtpSecret string `json:"secret"`
97 base64.StdEncoding.EncodeToString(qrPng.Bytes()),
101 WriteJsonResponse(SuccessResponse(response), c)
106 func GetMarketConfig(c *gin.Context) {
107 query := &MarketConfigQuery{}
109 query.In.User = GetUser(c)
110 query.In.Market = c.Param("name")
115 func GetMarketBalance(c *gin.Context) {
116 query := &MarketBalanceQuery{}
118 query.In.User = GetUser(c)
119 query.In.Market = c.Param("name")
120 query.In.Currency = "BTC"
125 func UpdateMarketConfig(c *gin.Context) {
126 query := &UpdateMarketConfigQuery{}
128 query.In.User = GetUser(c)
129 query.In.Market = c.Param("name")
130 query.In.Key = c.PostForm("key")
131 query.In.Secret = c.PostForm("secret")