From: Florian Forster Date: Tue, 30 Jan 2018 08:32:48 +0000 (+0100) Subject: Package app: Implement User.DeleteToken() and User.String() X-Git-Url: https://git.octo.it/?p=kraftakt.git;a=commitdiff_plain;h=68e9c0c9f6290ef3cbf08962587ae2dbf351ad92 Package app: Implement User.DeleteToken() and User.String() --- diff --git a/app/user.go b/app/user.go index d5b8452..ffe65e9 100644 --- a/app/user.go +++ b/app/user.go @@ -86,6 +86,11 @@ func (u *User) SetToken(ctx context.Context, svc string, tok *oauth2.Token) erro 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) @@ -103,6 +108,10 @@ func (u *User) OAuthClient(ctx context.Context, svc string, cfg *oauth2.Config) }), nil } +func (u *User) String() string { + return u.Email +} + type persistingTokenSource struct { ctx context.Context t *oauth2.Token