Skip to content

Commit

Permalink
Merge pull request #50 from aau-network-security/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mrtrkmn authored Apr 19, 2021
2 parents 7600c12 + baad7de commit 9fd57b7
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 91 deletions.
1 change: 1 addition & 0 deletions database/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var (

UpdateEventLastaccessedDate = "UPDATE team SET last_access = $2 WHERE tag = $1"
UpdateTeamSolvedChl = "UPDATE team SET solved_challenges = $2 WHERE tag = $1"
UpdateTeamPassword = "UPDATE team SET password = $1 WHERE tag = $2 and event_id = $3"

QuerySolvedChls = "SELECT solved_challenges FROM team WHERE tag=$1"
QueryEventTable = "SELECT * FROM event"
Expand Down
19 changes: 19 additions & 0 deletions database/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ type Store interface {
SetEventStatus(*pb.SetEventStatusRequest) (int32, error)
UpdateTeamSolvedChallenge(*pb.UpdateTeamSolvedChallengeRequest) (string, error)
UpdateTeamLastAccess(*pb.UpdateTeamLastAccessRequest) (string, error)
UpdateTeamPassword(in *pb.UpdateTeamPassRequest) error
GetEventID(in *pb.GetEventIDReq) (int32, error)
UpdateCloseEvent(*pb.UpdateEventRequest) (string, error)
}

Expand Down Expand Up @@ -250,6 +252,23 @@ func (s *store) UpdateTeamSolvedChallenge(in *pb.UpdateTeamSolvedChallengeReques
return OK, nil
}

func (s *store) UpdateTeamPassword(in *pb.UpdateTeamPassRequest) error {
_, err := s.db.Exec(UpdateTeamPassword, in.EncryptedPass, in.TeamID, in.EventID)
if err != nil {
return err
}
return nil
}

func (s *store) GetEventID(in *pb.GetEventIDReq) (int32, error) {

var eventId int32
if err := s.db.QueryRow(QueryEventId, in.EventTag).Scan(&eventId); err != nil && !strings.Contains(err.Error(), "no rows in result set") {
return -1, err
}
return eventId, nil
}

func (s *store) UpdateTeamLastAccess(in *pb.UpdateTeamLastAccessRequest) (string, error) {
s.m.Lock()
defer s.m.Unlock()
Expand Down
Loading

0 comments on commit 9fd57b7

Please sign in to comment.