i wanted to add full cahce but i dont have time :(
This commit is contained in:
@@ -88,33 +88,24 @@ func HttpHandleLogin(response http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
var client = Client{Name: username}
|
||||
if len(client.Name) < 8 {
|
||||
if len(username) < 8 {
|
||||
http.Error(response, "no or short password", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
ctx := request.Context()
|
||||
var (
|
||||
clientId uint32
|
||||
err error
|
||||
ctx = request.Context()
|
||||
)
|
||||
|
||||
err := DbSetClientByName(ctx, &client)
|
||||
clientId, err = CacheGetIdByName(username)
|
||||
if err != nil {
|
||||
http.Error(response, "bad login", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
clientId, err = DbGetIdByClientName(ctx, username)
|
||||
if err != nil {
|
||||
|
||||
_, err = CacheGetClientById(client.Id)
|
||||
if err == nil {
|
||||
otherLoggedIn, err := CacheGetClientById(client.Id)
|
||||
if err == nil {
|
||||
otherLoggedIn.WsConn.CloseNow()
|
||||
}
|
||||
}
|
||||
|
||||
token, err := TokenCreate(client.Id)
|
||||
if err != nil {
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
}
|
||||
response.Write([]byte(token))
|
||||
}
|
||||
|
||||
func HttpHandleGroupCreate(response http.ResponseWriter, request *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user