package controllers
|
|
import (
|
"webserver/middlewares"
|
"fmt"
|
"github.com/gin-gonic/gin"
|
)
|
|
const userId string = "abc123"
|
|
func Signup(c *gin.Context) {
|
//var people PeoperController
|
//people.CreatePerson(c)
|
}
|
|
func Login(c *gin.Context) {
|
//var person models.Person
|
//c.BindJSON(&person)
|
//sinpass := person.Password
|
//fmt.Println(sinpass, person.UserName)
|
//
|
//var getDB = models.GetDB()
|
//if err := getDB.Where("user_name = ?", person.UserName).First(&person).Error; err != nil {
|
// fmt.Println("error")
|
// c.AbortWithStatus(404)
|
//} else {
|
// fmt.Println(person)
|
// if person.Password != sinpass {
|
// c.AbortWithStatus(500)
|
// }
|
// Auth(c)
|
//}
|
|
}
|
|
func Auth(c *gin.Context) {
|
|
token, err := middlewares.GenerateToken([]byte(middlewares.SigningKey), userId)
|
if err != nil {
|
fmt.Println(err)
|
|
}
|
c.JSON(200, token)
|
}
|