Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(discord): prompt only if permissions have changed #469

Merged
merged 1 commit into from Oct 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 12 additions & 11 deletions providers/discord/discord.go
Expand Up @@ -5,14 +5,13 @@ package discord
import (
"bytes"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"

"github.com/markbates/goth"
"golang.org/x/oauth2"

"fmt"
"net/http"
)

const (
Expand Down Expand Up @@ -85,8 +84,11 @@ func (p *Provider) Debug(debug bool) {}

// BeginAuth asks Discord for an authentication end-point.
func (p *Provider) BeginAuth(state string) (goth.Session, error) {

url := p.config.AuthCodeURL(state, oauth2.AccessTypeOnline)
url := p.config.AuthCodeURL(
state,
oauth2.AccessTypeOnline,
oauth2.SetAuthURLParam("prompt", "none"),
)

s := &Session{
AuthURL: url,
Expand All @@ -96,7 +98,6 @@ func (p *Provider) BeginAuth(state string) (goth.Session, error) {

// FetchUser will go to Discord and access basic info about the user.
func (p *Provider) FetchUser(session goth.Session) (goth.User, error) {

s := session.(*Session)

user := goth.User{
Expand Down Expand Up @@ -164,9 +165,9 @@ func userFromReader(r io.Reader, user *goth.User) error {
return err
}

//If this prefix is present, the image should be available as a gif,
//See : https://discord.com/developers/docs/reference#image-formatting
//Introduced by : Yyewolf
// If this prefix is present, the image should be available as a gif,
// See : https://discord.com/developers/docs/reference#image-formatting
// Introduced by : Yyewolf

if u.AvatarID != "" {
avatarExtension := ".jpg"
Expand Down Expand Up @@ -207,12 +208,12 @@ func newConfig(p *Provider, scopes []string) *oauth2.Config {
return c
}

//RefreshTokenAvailable refresh token is provided by auth provider or not
// RefreshTokenAvailable refresh token is provided by auth provider or not
func (p *Provider) RefreshTokenAvailable() bool {
return true
}

//RefreshToken get new access token based on the refresh token
// RefreshToken get new access token based on the refresh token
func (p *Provider) RefreshToken(refreshToken string) (*oauth2.Token, error) {
token := &oauth2.Token{RefreshToken: refreshToken}
ts := p.config.TokenSource(oauth2.NoContext, token)
Expand Down