fix login

This commit is contained in:
2025-05-20 02:04:13 +07:00
parent e0d39bbd72
commit 7de3a6324f
6 changed files with 60 additions and 30 deletions
+3 -2
View File
@@ -8,8 +8,9 @@ import (
func mapTeamsToTeamAdvanced(team *models.Team) *proto.TeamAdvanced {
return &proto.TeamAdvanced{
Id: team.ID,
Name: team.Name,
Id: team.ID,
Name: team.Name,
Password: team.Password,
}
}
-5
View File
@@ -30,11 +30,6 @@ func NewRepository() (*Repository, error) {
if err != nil {
return nil, err
}
// for tests
// _, err = db.Exec("insert into teams (id, name, password) values (1, \"name\", \"pass\");")
// if err != nil {
// return nil, err
// }
return &Repository{db: db}, nil
}
+9 -2
View File
@@ -2,6 +2,7 @@ package services
import (
"context"
"encoding/base64"
"encoding/json"
"evening_detective/internal/models"
"evening_detective/internal/modules/password"
@@ -96,7 +97,10 @@ func (s *Services) GetTeam(ctx context.Context, req *proto.GetTeamReq) (*proto.G
}
res = append(res, newAction)
}
return &proto.GetTeamRsp{Actions: res}, err
return &proto.GetTeamRsp{
Name: team.Name,
Actions: res,
}, err
}
func (s *Services) GetTeamsCSV(ctx context.Context, req *proto.GetTeamsCSVReq) (*proto.GetTeamsCSVRsp, error) {
@@ -154,7 +158,10 @@ func (s *Services) getTeam(ctx context.Context) (*models.Team, error) {
if !ok {
return nil, status.Errorf(codes.Unauthenticated, "error creds")
}
teamId := teamIdArr[0]
teamId, err := base64.StdEncoding.DecodeString(teamIdArr[0])
if err != nil {
return nil, status.Errorf(codes.Unauthenticated, "error creds")
}
passwordArr, ok := md["password"]
if !ok {