mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 10:07:21 +02:00
fixed issue updating team member roles
This commit is contained in:
parent
30a9845422
commit
3c25a4a00a
@ -33,7 +33,7 @@ WHERE user_id = ? AND team_id = ?
|
|||||||
|
|
||||||
// SQL Queries to retrieve a member's role by id and user.
|
// SQL Queries to retrieve a member's role by id and user.
|
||||||
const roleFindStmt = `
|
const roleFindStmt = `
|
||||||
SELECT role FROM members
|
SELECT id, team_id, user_id, role FROM members
|
||||||
WHERE user_id = ? AND team_id = ?
|
WHERE user_id = ? AND team_id = ?
|
||||||
`
|
`
|
||||||
|
|
||||||
|
@ -179,6 +179,11 @@ func AdminSettingsUpdate(w http.ResponseWriter, r *http.Request, u *User) error
|
|||||||
|
|
||||||
settings.OpenInvitations = (r.FormValue("OpenInvitations") == "on")
|
settings.OpenInvitations = (r.FormValue("OpenInvitations") == "on")
|
||||||
|
|
||||||
|
// validate user input
|
||||||
|
if err := settings.Validate(); err != nil {
|
||||||
|
return RenderError(w, err, http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
|
||||||
// persist changes
|
// persist changes
|
||||||
if err := database.SaveSettings(settings); err != nil {
|
if err := database.SaveSettings(settings); err != nil {
|
||||||
return RenderError(w, err, http.StatusBadRequest)
|
return RenderError(w, err, http.StatusBadRequest)
|
||||||
@ -245,8 +250,8 @@ func InstallPost(w http.ResponseWriter, r *http.Request) error {
|
|||||||
settings := Settings{}
|
settings := Settings{}
|
||||||
settings.Domain = r.FormValue("Domain")
|
settings.Domain = r.FormValue("Domain")
|
||||||
settings.Scheme = r.FormValue("Scheme")
|
settings.Scheme = r.FormValue("Scheme")
|
||||||
settings.GitHubApiUrl = "https://api.github.com";
|
settings.GitHubApiUrl = "https://api.github.com"
|
||||||
settings.GitHubDomain = "github.com";
|
settings.GitHubDomain = "github.com"
|
||||||
database.SaveSettings(&settings)
|
database.SaveSettings(&settings)
|
||||||
|
|
||||||
// add the user to the session object
|
// add the user to the session object
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/drone/drone/pkg/database"
|
"github.com/drone/drone/pkg/database"
|
||||||
@ -67,6 +68,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error {
|
|||||||
// exchange code for an auth token
|
// exchange code for an auth token
|
||||||
token, err := oauth.GrantToken(code)
|
token, err := oauth.GrantToken(code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("Error granting GitHub authorization token")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,6 +79,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error {
|
|||||||
// get the user information
|
// get the user information
|
||||||
githubUser, err := client.Users.Current()
|
githubUser, err := client.Users.Current()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Println("Error retrieving currently authenticated GitHub user")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +87,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error {
|
|||||||
u.GithubToken = token.AccessToken
|
u.GithubToken = token.AccessToken
|
||||||
u.GithubLogin = githubUser.Login
|
u.GithubLogin = githubUser.Login
|
||||||
if err := database.SaveUser(u); err != nil {
|
if err := database.SaveUser(u); err != nil {
|
||||||
|
log.Println("Error persisting user's GitHub auth token to the database")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user