🎨 Little code formatting

This commit is contained in:
Maxim Lebedev 2022-02-18 02:53:39 +05:00
parent b5c29dd553
commit 0cecea8d13
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
3 changed files with 6 additions and 9 deletions

View File

@ -39,12 +39,8 @@ func (uc *authUseCase) Generate(ctx context.Context, opts auth.GenerateOptions)
// information in the token is not guaranteed and is completely optional:
// https://indieauth.net/source/#profile-information
if opts.Scope.Has(domain.ScopeProfile) {
userInfo, _ = uc.profiles.Get(ctx, opts.Me)
// NOTE(toby3d): 'email' Scope depends on 'profile'
// Scope. Hide the email field if this information has
// not been requested.
if userInfo != nil && userInfo.Email != nil && !opts.Scope.Has(domain.ScopeEmail) {
if userInfo, err = uc.profiles.Get(ctx, opts.Me); err == nil &&
userInfo.Email != nil && !opts.Scope.Has(domain.ScopeEmail) {
userInfo.Email = nil
}
}

View File

@ -29,8 +29,8 @@ type (
NewTokenOptions struct {
Expiration time.Duration
Issuer *ClientID
Subject *Me
Profile *Profile
Subject *Me
Scope Scopes
Secret []byte
Algorithm string
@ -52,7 +52,7 @@ var DefaultNewTokenOptions = NewTokenOptions{
}
// NewToken create a new token by provided options.
//nolint: cyclop
//nolint: funlen,cyclop
func NewToken(opts NewTokenOptions) (*Token, error) {
if opts.NonceLength == 0 {
opts.NonceLength = DefaultNewTokenOptions.NonceLength

View File

@ -86,7 +86,8 @@ func (repo *httpProfileRepository) Get(ctx context.Context, me *domain.Me) (*dom
}
}
if result.GetName() == "" && result.GetURL() == nil && result.GetPhoto() == nil && result.GetEmail() == nil {
if result.GetName() == "" && result.GetURL() == nil &&
result.GetPhoto() == nil && result.GetEmail() == nil {
return nil, profile.ErrNotExist
}