Package app: Implement User.DeleteToken() and User.String()
authorFlorian Forster <ff@octo.it>
Tue, 30 Jan 2018 08:32:48 +0000 (09:32 +0100)
committerFlorian Forster <ff@octo.it>
Tue, 30 Jan 2018 08:32:48 +0000 (09:32 +0100)
app/user.go

index d5b8452..ffe65e9 100644 (file)
@@ -86,6 +86,11 @@ func (u *User) SetToken(ctx context.Context, svc string, tok *oauth2.Token) erro
        return err
 }
 
        return err
 }
 
+func (u *User) DeleteToken(ctx context.Context, svc string) error {
+       key := datastore.NewKey(ctx, "Token", svc, 0, u.key)
+       return datastore.Delete(ctx, key)
+}
+
 func (u *User) OAuthClient(ctx context.Context, svc string, cfg *oauth2.Config) (*http.Client, error) {
        key := datastore.NewKey(ctx, "Token", svc, 0, u.key)
 
 func (u *User) OAuthClient(ctx context.Context, svc string, cfg *oauth2.Config) (*http.Client, error) {
        key := datastore.NewKey(ctx, "Token", svc, 0, u.key)
 
@@ -103,6 +108,10 @@ func (u *User) OAuthClient(ctx context.Context, svc string, cfg *oauth2.Config)
        }), nil
 }
 
        }), nil
 }
 
+func (u *User) String() string {
+       return u.Email
+}
+
 type persistingTokenSource struct {
        ctx context.Context
        t   *oauth2.Token
 type persistingTokenSource struct {
        ctx context.Context
        t   *oauth2.Token