first key exchange thing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package rest_handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
|
||||
"gitea.elara.ws/Hazel/hangman/internal/game"
|
||||
@@ -11,7 +12,8 @@ func CreateUser(c echo.Context) error {
|
||||
session := game.GetSession(c.Param("session"))
|
||||
|
||||
type BodyContent struct {
|
||||
Name string
|
||||
Name string
|
||||
PublicKey string
|
||||
}
|
||||
var bodyContent BodyContent
|
||||
|
||||
@@ -20,7 +22,9 @@ func CreateUser(c echo.Context) error {
|
||||
return c.String(http.StatusBadRequest, err.Error())
|
||||
}
|
||||
|
||||
user := game.NewUser(bodyContent.Name)
|
||||
pub, _ := base64.StdEncoding.DecodeString(bodyContent.PublicKey)
|
||||
user := game.NewUser(bodyContent.Name, pub)
|
||||
session.AddUser(user)
|
||||
|
||||
return c.JSON(http.StatusOK, user)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user