mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 02:11:01 +00:00
Fix team invites
This commit is contained in:
parent
6c2b64dd55
commit
e36eacb0fe
1 changed files with 6 additions and 6 deletions
|
@ -173,7 +173,7 @@ func TeamMemberInvite(w http.ResponseWriter, r *http.Request, u *User) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate a token that is valid for 3 days to join the team
|
// generate a token that is valid for 3 days to join the team
|
||||||
token := authcookie.New(team.Name, time.Now().Add(72*time.Hour), secret)
|
token := authcookie.New(strconv.Itoa(int(team.ID)), time.Now().Add(72*time.Hour), secret)
|
||||||
|
|
||||||
// hostname from settings
|
// hostname from settings
|
||||||
hostname := database.SettingsMust().URL().String()
|
hostname := database.SettingsMust().URL().String()
|
||||||
|
@ -202,14 +202,14 @@ func TeamMemberInvite(w http.ResponseWriter, r *http.Request, u *User) error {
|
||||||
func TeamMemberAccept(w http.ResponseWriter, r *http.Request, u *User) error {
|
func TeamMemberAccept(w http.ResponseWriter, r *http.Request, u *User) error {
|
||||||
// get the team name from the token
|
// get the team name from the token
|
||||||
token := r.FormValue("token")
|
token := r.FormValue("token")
|
||||||
teamName := authcookie.Login(token, secret)
|
teamToken := authcookie.Login(token, secret)
|
||||||
if len(teamName) == 0 {
|
teamId, err := strconv.Atoi(teamToken)
|
||||||
|
if err != nil || teamId == 0 {
|
||||||
return ErrInvalidTeamName
|
return ErrInvalidTeamName
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the team from the database
|
// get the team from the database
|
||||||
// TODO it might make more sense to use the ID in case the Slug changes
|
team, err := database.GetTeam(int64(teamId))
|
||||||
team, err := database.GetTeamSlug(teamName)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return RenderError(w, err, http.StatusNotFound)
|
return RenderError(w, err, http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
@ -222,6 +222,6 @@ func TeamMemberAccept(w http.ResponseWriter, r *http.Request, u *User) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// send the user to the dashboard
|
// send the user to the dashboard
|
||||||
http.Redirect(w, r, "/dashboard/team/"+team.Name, http.StatusSeeOther)
|
http.Redirect(w, r, "/dashboard/team/"+team.Slug, http.StatusSeeOther)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue