fixed issue updating team member roles
This commit is contained in:
parent
30a9845422
commit
3c25a4a00a
3 changed files with 12 additions and 3 deletions
|
@ -33,7 +33,7 @@ WHERE user_id = ? AND team_id = ?
|
|||
|
||||
// SQL Queries to retrieve a member's role by id and user.
|
||||
const roleFindStmt = `
|
||||
SELECT role FROM members
|
||||
SELECT id, team_id, user_id, role FROM members
|
||||
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")
|
||||
|
||||
// validate user input
|
||||
if err := settings.Validate(); err != nil {
|
||||
return RenderError(w, err, http.StatusBadRequest)
|
||||
}
|
||||
|
||||
// persist changes
|
||||
if err := database.SaveSettings(settings); err != nil {
|
||||
return RenderError(w, err, http.StatusBadRequest)
|
||||
|
@ -245,8 +250,8 @@ func InstallPost(w http.ResponseWriter, r *http.Request) error {
|
|||
settings := Settings{}
|
||||
settings.Domain = r.FormValue("Domain")
|
||||
settings.Scheme = r.FormValue("Scheme")
|
||||
settings.GitHubApiUrl = "https://api.github.com";
|
||||
settings.GitHubDomain = "github.com";
|
||||
settings.GitHubApiUrl = "https://api.github.com"
|
||||
settings.GitHubDomain = "github.com"
|
||||
database.SaveSettings(&settings)
|
||||
|
||||
// add the user to the session object
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package handler
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"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
|
||||
token, err := oauth.GrantToken(code)
|
||||
if err != nil {
|
||||
log.Println("Error granting GitHub authorization token")
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -77,6 +79,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error {
|
|||
// get the user information
|
||||
githubUser, err := client.Users.Current()
|
||||
if err != nil {
|
||||
log.Println("Error retrieving currently authenticated GitHub user")
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -84,6 +87,7 @@ func LinkGithub(w http.ResponseWriter, r *http.Request, u *User) error {
|
|||
u.GithubToken = token.AccessToken
|
||||
u.GithubLogin = githubUser.Login
|
||||
if err := database.SaveUser(u); err != nil {
|
||||
log.Println("Error persisting user's GitHub auth token to the database")
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue