mirror of
https://github.com/pagefaultgames/rogueserver.git
synced 2025-03-31 02:02:54 +08:00
chore: Update variable name for Discord guild ID in account package
This commit is contained in:
parent
f609ec5ee8
commit
715fe93440
@ -32,7 +32,7 @@ var (
|
||||
DiscordCallbackURL string
|
||||
|
||||
DiscordSession *discordgo.Session
|
||||
DiscordGuildId string
|
||||
DiscordGuildID string
|
||||
)
|
||||
|
||||
func HandleDiscordCallback(w http.ResponseWriter, r *http.Request) (string, error) {
|
||||
@ -111,15 +111,15 @@ func RetrieveDiscordId(code string) (string, error) {
|
||||
return user.Id, nil
|
||||
}
|
||||
|
||||
func IsUserDiscordAdmin(discordId string, discordGuildId string) (bool, error) {
|
||||
func IsUserDiscordAdmin(discordId string, discordGuildID string) (bool, error) {
|
||||
// fetch all roles from discord
|
||||
roles, err := DiscordSession.GuildRoles(discordGuildId)
|
||||
roles, err := DiscordSession.GuildRoles(discordGuildID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
// fetch all roles from user
|
||||
userRoles, err := DiscordSession.GuildMember(discordGuildId, discordId)
|
||||
userRoles, err := DiscordSession.GuildMember(discordGuildID, discordId)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func handleAccountInfo(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
hasAdminRole, _ := account.IsUserDiscordAdmin(discordId, account.DiscordGuildId)
|
||||
hasAdminRole, _ := account.IsUserDiscordAdmin(discordId, account.DiscordGuildID)
|
||||
|
||||
response, err := account.Info(username, discordId, googleId, uuid, hasAdminRole)
|
||||
if err != nil {
|
||||
@ -683,7 +683,7 @@ func handleAdminDiscordLink(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
hasRole, err := account.IsUserDiscordAdmin(userDiscordId, account.DiscordGuildId)
|
||||
hasRole, err := account.IsUserDiscordAdmin(userDiscordId, account.DiscordGuildID)
|
||||
|
||||
if !hasRole || err != nil {
|
||||
httpError(w, r, fmt.Errorf("user does not have the required role"), http.StatusForbidden)
|
||||
|
@ -71,7 +71,7 @@ func main() {
|
||||
account.GoogleClientSecret = *googlesecretid
|
||||
account.GoogleCallbackURL = *callbackurl + "/auth/google/callback"
|
||||
account.DiscordSession, _ = discordgo.New("Bot " + *discordbottoken)
|
||||
account.DiscordGuildId = *discordguildid
|
||||
account.DiscordGuildID = *discordguildid
|
||||
// register gob types
|
||||
gob.Register([]interface{}{})
|
||||
gob.Register(map[string]interface{}{})
|
||||
|
Loading…
x
Reference in New Issue
Block a user