Skip to content

Commit

Permalink
Merge pull request #469 from lrstanley/fix/issue-401
Browse files Browse the repository at this point in the history
fix(discord): prompt only if permissions have changed
  • Loading branch information
techknowlogick authored Oct 12, 2022
2 parents 7593a57 + ca5127c commit dc95a43
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions providers/discord/discord.go
Original file line number Diff line number Diff line change
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

0 comments on commit dc95a43

Please sign in to comment.