You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnnil, connect.NewError(connect.CodeInvalidArgument, errors.New("Received invalid Expiration Time, it is a required parameter."))
58
+
}
59
+
60
+
// TODO: Parse and validate scopes before storing
61
+
// Until we do that, we store empty scopes.
62
+
varscopes []string
63
+
46
64
conn, err:=getConnection(ctx, s.connectionPool)
47
65
iferr!=nil {
48
66
returnnil, err
49
67
}
50
68
51
-
_, err=s.getUser(ctx, conn)
69
+
_, userID, err:=s.getUser(ctx, conn)
52
70
iferr!=nil {
53
71
returnnil, err
54
72
}
55
73
56
-
returnnil, connect.NewError(connect.CodeUnimplemented, errors.New("gitpod.experimental.v1.TokensService.CreatePersonalAccessToken is not implemented"))
74
+
pat, err:=auth.GeneratePersonalAccessToken(s.signer)
75
+
iferr!=nil {
76
+
log.WithError(err).Errorf("Failed to generate personal access token for user %s", userID.String())
77
+
returnnil, connect.NewError(connect.CodeInternal, errors.New("Failed to generate personal access token."))
78
+
}
79
+
80
+
hash, err:=pat.ValueHash()
81
+
iferr!=nil {
82
+
log.WithError(err).Errorf("Failed to generate personal access token value hash for user %s", userID.String())
83
+
returnnil, connect.NewError(connect.CodeInternal, errors.New("Failed to compute personal access token hash."))
returnnil, connect.NewError(connect.CodeUnimplemented, errors.New("gitpod.experimental.v1.TokensService.DeletePersonalAccessToken is not implemented"))
returnnil, connect.NewError(connect.CodePermissionDenied, errors.New("This feature is currently in beta. If you would like to be part of the beta, please contact us."))
214
+
returnnil, uuid.Nil, connect.NewError(connect.CodePermissionDenied, errors.New("This feature is currently in beta. If you would like to be part of the beta, please contact us."))
215
+
}
216
+
217
+
userID, err:=uuid.Parse(user.ID)
218
+
iferr!=nil {
219
+
returnnil, uuid.Nil, connect.NewError(connect.CodeInternal, errors.New("Failed to parse user ID as UUID. Please contact support."))
174
220
}
175
221
176
-
returnuser, nil
222
+
returnuser, userID, nil
177
223
}
178
224
179
225
funcgetConnection(ctx context.Context, pool proxy.ServerConnectionPool) (protocol.APIInterface, error) {
0 commit comments