refactor: remove deprecated Sessions and AccessTokens settings

- Remove ListSessions and RevokeSession RPC endpoints
- Remove Session message and SessionsSetting from UserSetting
- Remove ACCESS_TOKENS key and AccessTokensSetting
- Update references to use RefreshTokensUserSetting with its own ClientInfo
- Remove UserSessionsSection frontend component
- Clean up user store to remove session and access token settings
- Regenerate protobuf files

The system now uses:
- REFRESH_TOKENS for session management with sliding expiration
- PERSONAL_ACCESS_TOKENS for long-lived API tokens
This commit is contained in:
Steven 2025-12-19 08:35:57 +08:00
parent a6c32908a0
commit d0c3908168
46 changed files with 331 additions and 2681 deletions

View File

@ -106,21 +106,6 @@ service UserService {
option (google.api.method_signature) = "name";
}
// ListSessions returns a list of active login sessions for a user.
// Each session represents a browser/device where the user is logged in.
// Sessions are backed by refresh tokens with sliding expiration.
rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {
option (google.api.http) = {get: "/api/v1/{parent=users/*}/sessions"};
option (google.api.method_signature) = "parent";
}
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
rpc RevokeSession(RevokeSessionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/{name=users/*/sessions/*}"};
option (google.api.method_signature) = "name";
}
// ListUserWebhooks returns a list of webhooks for a user.
rpc ListUserWebhooks(ListUserWebhooksRequest) returns (ListUserWebhooksResponse) {
option (google.api.http) = {get: "/api/v1/{parent=users/*}/webhooks"};
@ -392,8 +377,6 @@ message UserSetting {
oneof value {
GeneralSetting general_setting = 2;
SessionsSetting sessions_setting = 3;
AccessTokensSetting access_tokens_setting = 4;
WebhooksSetting webhooks_setting = 5;
}
@ -402,10 +385,6 @@ message UserSetting {
KEY_UNSPECIFIED = 0;
// GENERAL is the key for general user settings.
GENERAL = 1;
// SESSIONS is the key for user login sessions (refresh tokens).
SESSIONS = 2;
// ACCESS_TOKENS is the key for Personal Access Tokens (PATs).
ACCESS_TOKENS = 3;
// WEBHOOKS is the key for user webhooks.
WEBHOOKS = 4;
}
@ -422,18 +401,6 @@ message UserSetting {
string theme = 4 [(google.api.field_behavior) = OPTIONAL];
}
// User authentication sessions configuration.
message SessionsSetting {
// List of active login sessions.
repeated Session sessions = 1;
}
// Personal access tokens configuration.
message AccessTokensSetting {
// List of personal access tokens (PATs).
repeated PersonalAccessToken personal_access_tokens = 1;
}
// User webhooks configuration.
message WebhooksSetting {
// List of user webhooks.
@ -577,70 +544,6 @@ message DeletePersonalAccessTokenRequest {
];
}
// Session represents a user's login session on a specific device/browser.
// Sessions are backed by refresh tokens with sliding expiration.
message Session {
option (google.api.resource) = {
type: "memos.api.v1/Session"
pattern: "users/{user}/sessions/{session}"
name_field: "name"
};
// The resource name of the session.
// Format: users/{user}/sessions/{session}
string name = 1 [(google.api.field_behavior) = IDENTIFIER];
// The session ID.
string session_id = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
// The timestamp when the session was created.
google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
// The timestamp when the session was last accessed.
// Used for sliding expiration calculation (last_accessed_time + 2 weeks).
google.protobuf.Timestamp last_accessed_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
// Client information associated with this session.
ClientInfo client_info = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
message ClientInfo {
// User agent string of the client.
string user_agent = 1;
// IP address of the client.
string ip_address = 2;
// Optional. Device type (e.g., "mobile", "desktop", "tablet").
string device_type = 3 [(google.api.field_behavior) = OPTIONAL];
// Optional. Operating system (e.g., "iOS 17.0", "Windows 11").
string os = 4 [(google.api.field_behavior) = OPTIONAL];
// Optional. Browser name and version (e.g., "Chrome 119.0").
string browser = 5 [(google.api.field_behavior) = OPTIONAL];
}
}
message ListSessionsRequest {
// Required. The resource name of the parent.
// Format: users/{user}
string parent = 1 [
(google.api.field_behavior) = REQUIRED,
(google.api.resource_reference) = {type: "memos.api.v1/User"}
];
}
message ListSessionsResponse {
// The list of sessions.
repeated Session sessions = 1;
}
message RevokeSessionRequest {
// The name of the session to revoke.
// Format: users/{user}/sessions/{session}
string name = 1 [(google.api.field_behavior) = REQUIRED];
}
// UserWebhook represents a webhook owned by a user.
message UserWebhook {
// The name of the webhook.

View File

@ -68,12 +68,6 @@ const (
// UserServiceDeletePersonalAccessTokenProcedure is the fully-qualified name of the UserService's
// DeletePersonalAccessToken RPC.
UserServiceDeletePersonalAccessTokenProcedure = "/memos.api.v1.UserService/DeletePersonalAccessToken"
// UserServiceListSessionsProcedure is the fully-qualified name of the UserService's ListSessions
// RPC.
UserServiceListSessionsProcedure = "/memos.api.v1.UserService/ListSessions"
// UserServiceRevokeSessionProcedure is the fully-qualified name of the UserService's RevokeSession
// RPC.
UserServiceRevokeSessionProcedure = "/memos.api.v1.UserService/RevokeSession"
// UserServiceListUserWebhooksProcedure is the fully-qualified name of the UserService's
// ListUserWebhooks RPC.
UserServiceListUserWebhooksProcedure = "/memos.api.v1.UserService/ListUserWebhooks"
@ -130,13 +124,6 @@ type UserServiceClient interface {
CreatePersonalAccessToken(context.Context, *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(context.Context, *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error)
// ListSessions returns a list of active login sessions for a user.
// Each session represents a browser/device where the user is logged in.
// Sessions are backed by refresh tokens with sliding expiration.
ListSessions(context.Context, *connect.Request[v1.ListSessionsRequest]) (*connect.Response[v1.ListSessionsResponse], error)
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
RevokeSession(context.Context, *connect.Request[v1.RevokeSessionRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error)
// CreateUserWebhook creates a new webhook for a user.
@ -242,18 +229,6 @@ func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ..
connect.WithSchema(userServiceMethods.ByName("DeletePersonalAccessToken")),
connect.WithClientOptions(opts...),
),
listSessions: connect.NewClient[v1.ListSessionsRequest, v1.ListSessionsResponse](
httpClient,
baseURL+UserServiceListSessionsProcedure,
connect.WithSchema(userServiceMethods.ByName("ListSessions")),
connect.WithClientOptions(opts...),
),
revokeSession: connect.NewClient[v1.RevokeSessionRequest, emptypb.Empty](
httpClient,
baseURL+UserServiceRevokeSessionProcedure,
connect.WithSchema(userServiceMethods.ByName("RevokeSession")),
connect.WithClientOptions(opts...),
),
listUserWebhooks: connect.NewClient[v1.ListUserWebhooksRequest, v1.ListUserWebhooksResponse](
httpClient,
baseURL+UserServiceListUserWebhooksProcedure,
@ -314,8 +289,6 @@ type userServiceClient struct {
listPersonalAccessTokens *connect.Client[v1.ListPersonalAccessTokensRequest, v1.ListPersonalAccessTokensResponse]
createPersonalAccessToken *connect.Client[v1.CreatePersonalAccessTokenRequest, v1.CreatePersonalAccessTokenResponse]
deletePersonalAccessToken *connect.Client[v1.DeletePersonalAccessTokenRequest, emptypb.Empty]
listSessions *connect.Client[v1.ListSessionsRequest, v1.ListSessionsResponse]
revokeSession *connect.Client[v1.RevokeSessionRequest, emptypb.Empty]
listUserWebhooks *connect.Client[v1.ListUserWebhooksRequest, v1.ListUserWebhooksResponse]
createUserWebhook *connect.Client[v1.CreateUserWebhookRequest, v1.UserWebhook]
updateUserWebhook *connect.Client[v1.UpdateUserWebhookRequest, v1.UserWebhook]
@ -390,16 +363,6 @@ func (c *userServiceClient) DeletePersonalAccessToken(ctx context.Context, req *
return c.deletePersonalAccessToken.CallUnary(ctx, req)
}
// ListSessions calls memos.api.v1.UserService.ListSessions.
func (c *userServiceClient) ListSessions(ctx context.Context, req *connect.Request[v1.ListSessionsRequest]) (*connect.Response[v1.ListSessionsResponse], error) {
return c.listSessions.CallUnary(ctx, req)
}
// RevokeSession calls memos.api.v1.UserService.RevokeSession.
func (c *userServiceClient) RevokeSession(ctx context.Context, req *connect.Request[v1.RevokeSessionRequest]) (*connect.Response[emptypb.Empty], error) {
return c.revokeSession.CallUnary(ctx, req)
}
// ListUserWebhooks calls memos.api.v1.UserService.ListUserWebhooks.
func (c *userServiceClient) ListUserWebhooks(ctx context.Context, req *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error) {
return c.listUserWebhooks.CallUnary(ctx, req)
@ -468,13 +431,6 @@ type UserServiceHandler interface {
CreatePersonalAccessToken(context.Context, *connect.Request[v1.CreatePersonalAccessTokenRequest]) (*connect.Response[v1.CreatePersonalAccessTokenResponse], error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(context.Context, *connect.Request[v1.DeletePersonalAccessTokenRequest]) (*connect.Response[emptypb.Empty], error)
// ListSessions returns a list of active login sessions for a user.
// Each session represents a browser/device where the user is logged in.
// Sessions are backed by refresh tokens with sliding expiration.
ListSessions(context.Context, *connect.Request[v1.ListSessionsRequest]) (*connect.Response[v1.ListSessionsResponse], error)
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
RevokeSession(context.Context, *connect.Request[v1.RevokeSessionRequest]) (*connect.Response[emptypb.Empty], error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error)
// CreateUserWebhook creates a new webhook for a user.
@ -576,18 +532,6 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption
connect.WithSchema(userServiceMethods.ByName("DeletePersonalAccessToken")),
connect.WithHandlerOptions(opts...),
)
userServiceListSessionsHandler := connect.NewUnaryHandler(
UserServiceListSessionsProcedure,
svc.ListSessions,
connect.WithSchema(userServiceMethods.ByName("ListSessions")),
connect.WithHandlerOptions(opts...),
)
userServiceRevokeSessionHandler := connect.NewUnaryHandler(
UserServiceRevokeSessionProcedure,
svc.RevokeSession,
connect.WithSchema(userServiceMethods.ByName("RevokeSession")),
connect.WithHandlerOptions(opts...),
)
userServiceListUserWebhooksHandler := connect.NewUnaryHandler(
UserServiceListUserWebhooksProcedure,
svc.ListUserWebhooks,
@ -658,10 +602,6 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption
userServiceCreatePersonalAccessTokenHandler.ServeHTTP(w, r)
case UserServiceDeletePersonalAccessTokenProcedure:
userServiceDeletePersonalAccessTokenHandler.ServeHTTP(w, r)
case UserServiceListSessionsProcedure:
userServiceListSessionsHandler.ServeHTTP(w, r)
case UserServiceRevokeSessionProcedure:
userServiceRevokeSessionHandler.ServeHTTP(w, r)
case UserServiceListUserWebhooksProcedure:
userServiceListUserWebhooksHandler.ServeHTTP(w, r)
case UserServiceCreateUserWebhookProcedure:
@ -737,14 +677,6 @@ func (UnimplementedUserServiceHandler) DeletePersonalAccessToken(context.Context
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.DeletePersonalAccessToken is not implemented"))
}
func (UnimplementedUserServiceHandler) ListSessions(context.Context, *connect.Request[v1.ListSessionsRequest]) (*connect.Response[v1.ListSessionsResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListSessions is not implemented"))
}
func (UnimplementedUserServiceHandler) RevokeSession(context.Context, *connect.Request[v1.RevokeSessionRequest]) (*connect.Response[emptypb.Empty], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.RevokeSession is not implemented"))
}
func (UnimplementedUserServiceHandler) ListUserWebhooks(context.Context, *connect.Request[v1.ListUserWebhooksRequest]) (*connect.Response[v1.ListUserWebhooksResponse], error) {
return nil, connect.NewError(connect.CodeUnimplemented, errors.New("memos.api.v1.UserService.ListUserWebhooks is not implemented"))
}

File diff suppressed because it is too large Load Diff

View File

@ -668,84 +668,6 @@ func local_request_UserService_DeletePersonalAccessToken_0(ctx context.Context,
return msg, metadata, err
}
func request_UserService_ListSessions_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq ListSessionsRequest
metadata runtime.ServerMetadata
err error
)
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
val, ok := pathParams["parent"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
}
protoReq.Parent, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
}
msg, err := client.ListSessions(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_UserService_ListSessions_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq ListSessionsRequest
metadata runtime.ServerMetadata
err error
)
val, ok := pathParams["parent"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "parent")
}
protoReq.Parent, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "parent", err)
}
msg, err := server.ListSessions(ctx, &protoReq)
return msg, metadata, err
}
func request_UserService_RevokeSession_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RevokeSessionRequest
metadata runtime.ServerMetadata
err error
)
if req.Body != nil {
_, _ = io.Copy(io.Discard, req.Body)
}
val, ok := pathParams["name"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
}
protoReq.Name, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
}
msg, err := client.RevokeSession(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_UserService_RevokeSession_0(ctx context.Context, marshaler runtime.Marshaler, server UserServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq RevokeSessionRequest
metadata runtime.ServerMetadata
err error
)
val, ok := pathParams["name"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "name")
}
protoReq.Name, err = runtime.String(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "name", err)
}
msg, err := server.RevokeSession(ctx, &protoReq)
return msg, metadata, err
}
func request_UserService_ListUserWebhooks_0(ctx context.Context, marshaler runtime.Marshaler, client UserServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var (
protoReq ListUserWebhooksRequest
@ -1389,46 +1311,6 @@ func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
}
forward_UserService_DeletePersonalAccessToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_UserService_ListSessions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/ListSessions", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/sessions"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_UserService_ListSessions_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_UserService_ListSessions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodDelete, pattern_UserService_RevokeSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.UserService/RevokeSession", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/sessions/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_UserService_RevokeSession_0(annotatedContext, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_UserService_RevokeSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_UserService_ListUserWebhooks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -1830,40 +1712,6 @@ func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
}
forward_UserService_DeletePersonalAccessToken_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_UserService_ListSessions_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/ListSessions", runtime.WithHTTPPathPattern("/api/v1/{parent=users/*}/sessions"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_UserService_ListSessions_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_UserService_ListSessions_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodDelete, pattern_UserService_RevokeSession_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.UserService/RevokeSession", runtime.WithHTTPPathPattern("/api/v1/{name=users/*/sessions/*}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_UserService_RevokeSession_0(annotatedContext, inboundMarshaler, client, req, pathParams)
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
if err != nil {
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_UserService_RevokeSession_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle(http.MethodGet, pattern_UserService_ListUserWebhooks_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
@ -2000,8 +1848,6 @@ var (
pattern_UserService_ListPersonalAccessTokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "personalAccessTokens"}, ""))
pattern_UserService_CreatePersonalAccessToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "personalAccessTokens"}, ""))
pattern_UserService_DeletePersonalAccessToken_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "personalAccessTokens", "name"}, ""))
pattern_UserService_ListSessions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "sessions"}, ""))
pattern_UserService_RevokeSession_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "sessions", "name"}, ""))
pattern_UserService_ListUserWebhooks_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "webhooks"}, ""))
pattern_UserService_CreateUserWebhook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "users", "parent", "webhooks"}, ""))
pattern_UserService_UpdateUserWebhook_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 2, 3, 1, 0, 4, 4, 5, 4}, []string{"api", "v1", "users", "webhooks", "webhook.name"}, ""))
@ -2025,8 +1871,6 @@ var (
forward_UserService_ListPersonalAccessTokens_0 = runtime.ForwardResponseMessage
forward_UserService_CreatePersonalAccessToken_0 = runtime.ForwardResponseMessage
forward_UserService_DeletePersonalAccessToken_0 = runtime.ForwardResponseMessage
forward_UserService_ListSessions_0 = runtime.ForwardResponseMessage
forward_UserService_RevokeSession_0 = runtime.ForwardResponseMessage
forward_UserService_ListUserWebhooks_0 = runtime.ForwardResponseMessage
forward_UserService_CreateUserWebhook_0 = runtime.ForwardResponseMessage
forward_UserService_UpdateUserWebhook_0 = runtime.ForwardResponseMessage

View File

@ -33,8 +33,6 @@ const (
UserService_ListPersonalAccessTokens_FullMethodName = "/memos.api.v1.UserService/ListPersonalAccessTokens"
UserService_CreatePersonalAccessToken_FullMethodName = "/memos.api.v1.UserService/CreatePersonalAccessToken"
UserService_DeletePersonalAccessToken_FullMethodName = "/memos.api.v1.UserService/DeletePersonalAccessToken"
UserService_ListSessions_FullMethodName = "/memos.api.v1.UserService/ListSessions"
UserService_RevokeSession_FullMethodName = "/memos.api.v1.UserService/RevokeSession"
UserService_ListUserWebhooks_FullMethodName = "/memos.api.v1.UserService/ListUserWebhooks"
UserService_CreateUserWebhook_FullMethodName = "/memos.api.v1.UserService/CreateUserWebhook"
UserService_UpdateUserWebhook_FullMethodName = "/memos.api.v1.UserService/UpdateUserWebhook"
@ -79,13 +77,6 @@ type UserServiceClient interface {
CreatePersonalAccessToken(ctx context.Context, in *CreatePersonalAccessTokenRequest, opts ...grpc.CallOption) (*CreatePersonalAccessTokenResponse, error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(ctx context.Context, in *DeletePersonalAccessTokenRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// ListSessions returns a list of active login sessions for a user.
// Each session represents a browser/device where the user is logged in.
// Sessions are backed by refresh tokens with sliding expiration.
ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error)
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
RevokeSession(ctx context.Context, in *RevokeSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(ctx context.Context, in *ListUserWebhooksRequest, opts ...grpc.CallOption) (*ListUserWebhooksResponse, error)
// CreateUserWebhook creates a new webhook for a user.
@ -240,26 +231,6 @@ func (c *userServiceClient) DeletePersonalAccessToken(ctx context.Context, in *D
return out, nil
}
func (c *userServiceClient) ListSessions(ctx context.Context, in *ListSessionsRequest, opts ...grpc.CallOption) (*ListSessionsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListSessionsResponse)
err := c.cc.Invoke(ctx, UserService_ListSessions_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) RevokeSession(ctx context.Context, in *RevokeSessionRequest, opts ...grpc.CallOption) (*emptypb.Empty, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, UserService_RevokeSession_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *userServiceClient) ListUserWebhooks(ctx context.Context, in *ListUserWebhooksRequest, opts ...grpc.CallOption) (*ListUserWebhooksResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListUserWebhooksResponse)
@ -365,13 +336,6 @@ type UserServiceServer interface {
CreatePersonalAccessToken(context.Context, *CreatePersonalAccessTokenRequest) (*CreatePersonalAccessTokenResponse, error)
// DeletePersonalAccessToken deletes a Personal Access Token.
DeletePersonalAccessToken(context.Context, *DeletePersonalAccessTokenRequest) (*emptypb.Empty, error)
// ListSessions returns a list of active login sessions for a user.
// Each session represents a browser/device where the user is logged in.
// Sessions are backed by refresh tokens with sliding expiration.
ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error)
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
RevokeSession(context.Context, *RevokeSessionRequest) (*emptypb.Empty, error)
// ListUserWebhooks returns a list of webhooks for a user.
ListUserWebhooks(context.Context, *ListUserWebhooksRequest) (*ListUserWebhooksResponse, error)
// CreateUserWebhook creates a new webhook for a user.
@ -435,12 +399,6 @@ func (UnimplementedUserServiceServer) CreatePersonalAccessToken(context.Context,
func (UnimplementedUserServiceServer) DeletePersonalAccessToken(context.Context, *DeletePersonalAccessTokenRequest) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "method DeletePersonalAccessToken not implemented")
}
func (UnimplementedUserServiceServer) ListSessions(context.Context, *ListSessionsRequest) (*ListSessionsResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ListSessions not implemented")
}
func (UnimplementedUserServiceServer) RevokeSession(context.Context, *RevokeSessionRequest) (*emptypb.Empty, error) {
return nil, status.Error(codes.Unimplemented, "method RevokeSession not implemented")
}
func (UnimplementedUserServiceServer) ListUserWebhooks(context.Context, *ListUserWebhooksRequest) (*ListUserWebhooksResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ListUserWebhooks not implemented")
}
@ -717,42 +675,6 @@ func _UserService_DeletePersonalAccessToken_Handler(srv interface{}, ctx context
return interceptor(ctx, in, info, handler)
}
func _UserService_ListSessions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListSessionsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).ListSessions(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_ListSessions_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).ListSessions(ctx, req.(*ListSessionsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_RevokeSession_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(RevokeSessionRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(UserServiceServer).RevokeSession(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: UserService_RevokeSession_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(UserServiceServer).RevokeSession(ctx, req.(*RevokeSessionRequest))
}
return interceptor(ctx, in, info, handler)
}
func _UserService_ListUserWebhooks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListUserWebhooksRequest)
if err := dec(in); err != nil {
@ -938,14 +860,6 @@ var UserService_ServiceDesc = grpc.ServiceDesc{
MethodName: "DeletePersonalAccessToken",
Handler: _UserService_DeletePersonalAccessToken_Handler,
},
{
MethodName: "ListSessions",
Handler: _UserService_ListSessions_Handler,
},
{
MethodName: "RevokeSession",
Handler: _UserService_RevokeSession_Handler,
},
{
MethodName: "ListUserWebhooks",
Handler: _UserService_ListUserWebhooks_Handler,

View File

@ -1462,66 +1462,6 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Status'
/api/v1/users/{user}/sessions:
get:
tags:
- UserService
description: |-
ListSessions returns a list of active login sessions for a user.
Each session represents a browser/device where the user is logged in.
Sessions are backed by refresh tokens with sliding expiration.
operationId: UserService_ListSessions
parameters:
- name: user
in: path
description: The user id.
required: true
schema:
type: string
responses:
"200":
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ListSessionsResponse'
default:
description: Default error response
content:
application/json:
schema:
$ref: '#/components/schemas/Status'
/api/v1/users/{user}/sessions/{session}:
delete:
tags:
- UserService
description: |-
RevokeSession revokes a specific login session.
This invalidates the refresh token, forcing re-authentication on that device.
operationId: UserService_RevokeSession
parameters:
- name: user
in: path
description: The user id.
required: true
schema:
type: string
- name: session
in: path
description: The session id.
required: true
schema:
type: string
responses:
"200":
description: OK
content: {}
default:
description: Default error response
content:
application/json:
schema:
$ref: '#/components/schemas/Status'
/api/v1/users/{user}/settings:
get:
tags:
@ -2431,14 +2371,6 @@ components:
type: integer
description: The total count of personal access tokens.
format: int32
ListSessionsResponse:
type: object
properties:
sessions:
type: array
items:
$ref: '#/components/schemas/Session'
description: The list of sessions.
ListShortcutsResponse:
type: object
properties:
@ -2750,56 +2682,6 @@ components:
type: string
description: When the access token expires.
format: date-time
Session:
type: object
properties:
name:
type: string
description: |-
The resource name of the session.
Format: users/{user}/sessions/{session}
sessionId:
readOnly: true
type: string
description: The session ID.
createTime:
readOnly: true
type: string
description: The timestamp when the session was created.
format: date-time
lastAccessedTime:
readOnly: true
type: string
description: |-
The timestamp when the session was last accessed.
Used for sliding expiration calculation (last_accessed_time + 2 weeks).
format: date-time
clientInfo:
readOnly: true
allOf:
- $ref: '#/components/schemas/Session_ClientInfo'
description: Client information associated with this session.
description: |-
Session represents a user's login session on a specific device/browser.
Sessions are backed by refresh tokens with sliding expiration.
Session_ClientInfo:
type: object
properties:
userAgent:
type: string
description: User agent string of the client.
ipAddress:
type: string
description: IP address of the client.
deviceType:
type: string
description: Optional. Device type (e.g., "mobile", "desktop", "tablet").
os:
type: string
description: Optional. Operating system (e.g., "iOS 17.0", "Windows 11").
browser:
type: string
description: Optional. Browser name and version (e.g., "Chrome 119.0").
SetMemoAttachmentsRequest:
required:
- name
@ -3071,22 +2953,9 @@ components:
For example, "users/123/settings/GENERAL" for general settings.
generalSetting:
$ref: '#/components/schemas/UserSetting_GeneralSetting'
sessionsSetting:
$ref: '#/components/schemas/UserSetting_SessionsSetting'
accessTokensSetting:
$ref: '#/components/schemas/UserSetting_AccessTokensSetting'
webhooksSetting:
$ref: '#/components/schemas/UserSetting_WebhooksSetting'
description: User settings message
UserSetting_AccessTokensSetting:
type: object
properties:
personalAccessTokens:
type: array
items:
$ref: '#/components/schemas/PersonalAccessToken'
description: List of personal access tokens (PATs).
description: Personal access tokens configuration.
UserSetting_GeneralSetting:
type: object
properties:
@ -3103,15 +2972,6 @@ components:
This references a CSS file in the web/public/themes/ directory.
If not set, the default theme will be used.
description: General user settings configuration.
UserSetting_SessionsSetting:
type: object
properties:
sessions:
type: array
items:
$ref: '#/components/schemas/Session'
description: List of active login sessions.
description: User authentication sessions configuration.
UserSetting_WebhooksSetting:
type: object
properties:

View File

@ -28,10 +28,6 @@ const (
UserSetting_KEY_UNSPECIFIED UserSetting_Key = 0
// General user settings.
UserSetting_GENERAL UserSetting_Key = 1
// User authentication sessions.
UserSetting_SESSIONS UserSetting_Key = 2
// Access tokens for the user.
UserSetting_ACCESS_TOKENS UserSetting_Key = 3
// The shortcuts of the user.
UserSetting_SHORTCUTS UserSetting_Key = 4
// The webhooks of the user.
@ -47,8 +43,6 @@ var (
UserSetting_Key_name = map[int32]string{
0: "KEY_UNSPECIFIED",
1: "GENERAL",
2: "SESSIONS",
3: "ACCESS_TOKENS",
4: "SHORTCUTS",
5: "WEBHOOKS",
6: "REFRESH_TOKENS",
@ -57,8 +51,6 @@ var (
UserSetting_Key_value = map[string]int32{
"KEY_UNSPECIFIED": 0,
"GENERAL": 1,
"SESSIONS": 2,
"ACCESS_TOKENS": 3,
"SHORTCUTS": 4,
"WEBHOOKS": 5,
"REFRESH_TOKENS": 6,
@ -100,8 +92,6 @@ type UserSetting struct {
// Types that are valid to be assigned to Value:
//
// *UserSetting_General
// *UserSetting_Sessions
// *UserSetting_AccessTokens
// *UserSetting_Shortcuts
// *UserSetting_Webhooks
// *UserSetting_RefreshTokens
@ -171,24 +161,6 @@ func (x *UserSetting) GetGeneral() *GeneralUserSetting {
return nil
}
func (x *UserSetting) GetSessions() *SessionsUserSetting {
if x != nil {
if x, ok := x.Value.(*UserSetting_Sessions); ok {
return x.Sessions
}
}
return nil
}
func (x *UserSetting) GetAccessTokens() *AccessTokensUserSetting {
if x != nil {
if x, ok := x.Value.(*UserSetting_AccessTokens); ok {
return x.AccessTokens
}
}
return nil
}
func (x *UserSetting) GetShortcuts() *ShortcutsUserSetting {
if x != nil {
if x, ok := x.Value.(*UserSetting_Shortcuts); ok {
@ -233,14 +205,6 @@ type UserSetting_General struct {
General *GeneralUserSetting `protobuf:"bytes,3,opt,name=general,proto3,oneof"`
}
type UserSetting_Sessions struct {
Sessions *SessionsUserSetting `protobuf:"bytes,4,opt,name=sessions,proto3,oneof"`
}
type UserSetting_AccessTokens struct {
AccessTokens *AccessTokensUserSetting `protobuf:"bytes,5,opt,name=access_tokens,json=accessTokens,proto3,oneof"`
}
type UserSetting_Shortcuts struct {
Shortcuts *ShortcutsUserSetting `protobuf:"bytes,6,opt,name=shortcuts,proto3,oneof"`
}
@ -259,10 +223,6 @@ type UserSetting_PersonalAccessTokens struct {
func (*UserSetting_General) isUserSetting_Value() {}
func (*UserSetting_Sessions) isUserSetting_Value() {}
func (*UserSetting_AccessTokens) isUserSetting_Value() {}
func (*UserSetting_Shortcuts) isUserSetting_Value() {}
func (*UserSetting_Webhooks) isUserSetting_Value() {}
@ -335,94 +295,6 @@ func (x *GeneralUserSetting) GetTheme() string {
return ""
}
type SessionsUserSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
Sessions []*SessionsUserSetting_Session `protobuf:"bytes,1,rep,name=sessions,proto3" json:"sessions,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SessionsUserSetting) Reset() {
*x = SessionsUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SessionsUserSetting) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SessionsUserSetting) ProtoMessage() {}
func (x *SessionsUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SessionsUserSetting.ProtoReflect.Descriptor instead.
func (*SessionsUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{2}
}
func (x *SessionsUserSetting) GetSessions() []*SessionsUserSetting_Session {
if x != nil {
return x.Sessions
}
return nil
}
type AccessTokensUserSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
AccessTokens []*AccessTokensUserSetting_AccessToken `protobuf:"bytes,1,rep,name=access_tokens,json=accessTokens,proto3" json:"access_tokens,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AccessTokensUserSetting) Reset() {
*x = AccessTokensUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AccessTokensUserSetting) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AccessTokensUserSetting) ProtoMessage() {}
func (x *AccessTokensUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AccessTokensUserSetting.ProtoReflect.Descriptor instead.
func (*AccessTokensUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{3}
}
func (x *AccessTokensUserSetting) GetAccessTokens() []*AccessTokensUserSetting_AccessToken {
if x != nil {
return x.AccessTokens
}
return nil
}
type RefreshTokensUserSetting struct {
state protoimpl.MessageState `protogen:"open.v1"`
RefreshTokens []*RefreshTokensUserSetting_RefreshToken `protobuf:"bytes,1,rep,name=refresh_tokens,json=refreshTokens,proto3" json:"refresh_tokens,omitempty"`
@ -432,7 +304,7 @@ type RefreshTokensUserSetting struct {
func (x *RefreshTokensUserSetting) Reset() {
*x = RefreshTokensUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[4]
mi := &file_store_user_setting_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -444,7 +316,7 @@ func (x *RefreshTokensUserSetting) String() string {
func (*RefreshTokensUserSetting) ProtoMessage() {}
func (x *RefreshTokensUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[4]
mi := &file_store_user_setting_proto_msgTypes[2]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -457,7 +329,7 @@ func (x *RefreshTokensUserSetting) ProtoReflect() protoreflect.Message {
// Deprecated: Use RefreshTokensUserSetting.ProtoReflect.Descriptor instead.
func (*RefreshTokensUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{4}
return file_store_user_setting_proto_rawDescGZIP(), []int{2}
}
func (x *RefreshTokensUserSetting) GetRefreshTokens() []*RefreshTokensUserSetting_RefreshToken {
@ -476,7 +348,7 @@ type PersonalAccessTokensUserSetting struct {
func (x *PersonalAccessTokensUserSetting) Reset() {
*x = PersonalAccessTokensUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[5]
mi := &file_store_user_setting_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -488,7 +360,7 @@ func (x *PersonalAccessTokensUserSetting) String() string {
func (*PersonalAccessTokensUserSetting) ProtoMessage() {}
func (x *PersonalAccessTokensUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[5]
mi := &file_store_user_setting_proto_msgTypes[3]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -501,7 +373,7 @@ func (x *PersonalAccessTokensUserSetting) ProtoReflect() protoreflect.Message {
// Deprecated: Use PersonalAccessTokensUserSetting.ProtoReflect.Descriptor instead.
func (*PersonalAccessTokensUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{5}
return file_store_user_setting_proto_rawDescGZIP(), []int{3}
}
func (x *PersonalAccessTokensUserSetting) GetTokens() []*PersonalAccessTokensUserSetting_PersonalAccessToken {
@ -520,7 +392,7 @@ type ShortcutsUserSetting struct {
func (x *ShortcutsUserSetting) Reset() {
*x = ShortcutsUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[6]
mi := &file_store_user_setting_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -532,7 +404,7 @@ func (x *ShortcutsUserSetting) String() string {
func (*ShortcutsUserSetting) ProtoMessage() {}
func (x *ShortcutsUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[6]
mi := &file_store_user_setting_proto_msgTypes[4]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -545,7 +417,7 @@ func (x *ShortcutsUserSetting) ProtoReflect() protoreflect.Message {
// Deprecated: Use ShortcutsUserSetting.ProtoReflect.Descriptor instead.
func (*ShortcutsUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{6}
return file_store_user_setting_proto_rawDescGZIP(), []int{4}
}
func (x *ShortcutsUserSetting) GetShortcuts() []*ShortcutsUserSetting_Shortcut {
@ -564,7 +436,7 @@ type WebhooksUserSetting struct {
func (x *WebhooksUserSetting) Reset() {
*x = WebhooksUserSetting{}
mi := &file_store_user_setting_proto_msgTypes[7]
mi := &file_store_user_setting_proto_msgTypes[5]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -576,7 +448,7 @@ func (x *WebhooksUserSetting) String() string {
func (*WebhooksUserSetting) ProtoMessage() {}
func (x *WebhooksUserSetting) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[7]
mi := &file_store_user_setting_proto_msgTypes[5]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -589,7 +461,7 @@ func (x *WebhooksUserSetting) ProtoReflect() protoreflect.Message {
// Deprecated: Use WebhooksUserSetting.ProtoReflect.Descriptor instead.
func (*WebhooksUserSetting) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{7}
return file_store_user_setting_proto_rawDescGZIP(), []int{5}
}
func (x *WebhooksUserSetting) GetWebhooks() []*WebhooksUserSetting_Webhook {
@ -599,215 +471,6 @@ func (x *WebhooksUserSetting) GetWebhooks() []*WebhooksUserSetting_Webhook {
return nil
}
type SessionsUserSetting_Session struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Unique session identifier.
SessionId string `protobuf:"bytes,1,opt,name=session_id,json=sessionId,proto3" json:"session_id,omitempty"`
// Timestamp when the session was created.
CreateTime *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"`
// Timestamp when the session was last accessed.
// Used for sliding expiration calculation (last_accessed_time + 2 weeks).
LastAccessedTime *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=last_accessed_time,json=lastAccessedTime,proto3" json:"last_accessed_time,omitempty"`
// Client information associated with this session.
ClientInfo *SessionsUserSetting_ClientInfo `protobuf:"bytes,4,opt,name=client_info,json=clientInfo,proto3" json:"client_info,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SessionsUserSetting_Session) Reset() {
*x = SessionsUserSetting_Session{}
mi := &file_store_user_setting_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SessionsUserSetting_Session) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SessionsUserSetting_Session) ProtoMessage() {}
func (x *SessionsUserSetting_Session) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SessionsUserSetting_Session.ProtoReflect.Descriptor instead.
func (*SessionsUserSetting_Session) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{2, 0}
}
func (x *SessionsUserSetting_Session) GetSessionId() string {
if x != nil {
return x.SessionId
}
return ""
}
func (x *SessionsUserSetting_Session) GetCreateTime() *timestamppb.Timestamp {
if x != nil {
return x.CreateTime
}
return nil
}
func (x *SessionsUserSetting_Session) GetLastAccessedTime() *timestamppb.Timestamp {
if x != nil {
return x.LastAccessedTime
}
return nil
}
func (x *SessionsUserSetting_Session) GetClientInfo() *SessionsUserSetting_ClientInfo {
if x != nil {
return x.ClientInfo
}
return nil
}
type SessionsUserSetting_ClientInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
// User agent string of the client.
UserAgent string `protobuf:"bytes,1,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
// IP address of the client.
IpAddress string `protobuf:"bytes,2,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"`
// Optional. Device type (e.g., "mobile", "desktop", "tablet").
DeviceType string `protobuf:"bytes,3,opt,name=device_type,json=deviceType,proto3" json:"device_type,omitempty"`
// Optional. Operating system (e.g., "iOS 17.0", "Windows 11").
Os string `protobuf:"bytes,4,opt,name=os,proto3" json:"os,omitempty"`
// Optional. Browser name and version (e.g., "Chrome 119.0").
Browser string `protobuf:"bytes,5,opt,name=browser,proto3" json:"browser,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *SessionsUserSetting_ClientInfo) Reset() {
*x = SessionsUserSetting_ClientInfo{}
mi := &file_store_user_setting_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *SessionsUserSetting_ClientInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*SessionsUserSetting_ClientInfo) ProtoMessage() {}
func (x *SessionsUserSetting_ClientInfo) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use SessionsUserSetting_ClientInfo.ProtoReflect.Descriptor instead.
func (*SessionsUserSetting_ClientInfo) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{2, 1}
}
func (x *SessionsUserSetting_ClientInfo) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
func (x *SessionsUserSetting_ClientInfo) GetIpAddress() string {
if x != nil {
return x.IpAddress
}
return ""
}
func (x *SessionsUserSetting_ClientInfo) GetDeviceType() string {
if x != nil {
return x.DeviceType
}
return ""
}
func (x *SessionsUserSetting_ClientInfo) GetOs() string {
if x != nil {
return x.Os
}
return ""
}
func (x *SessionsUserSetting_ClientInfo) GetBrowser() string {
if x != nil {
return x.Browser
}
return ""
}
type AccessTokensUserSetting_AccessToken struct {
state protoimpl.MessageState `protogen:"open.v1"`
// The access token is a JWT token.
// Including expiration time, issuer, etc.
AccessToken string `protobuf:"bytes,1,opt,name=access_token,json=accessToken,proto3" json:"access_token,omitempty"`
// A description for the access token.
Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AccessTokensUserSetting_AccessToken) Reset() {
*x = AccessTokensUserSetting_AccessToken{}
mi := &file_store_user_setting_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AccessTokensUserSetting_AccessToken) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AccessTokensUserSetting_AccessToken) ProtoMessage() {}
func (x *AccessTokensUserSetting_AccessToken) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AccessTokensUserSetting_AccessToken.ProtoReflect.Descriptor instead.
func (*AccessTokensUserSetting_AccessToken) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{3, 0}
}
func (x *AccessTokensUserSetting_AccessToken) GetAccessToken() string {
if x != nil {
return x.AccessToken
}
return ""
}
func (x *AccessTokensUserSetting_AccessToken) GetDescription() string {
if x != nil {
return x.Description
}
return ""
}
type RefreshTokensUserSetting_RefreshToken struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Unique identifier (matches 'tid' claim in JWT)
@ -817,7 +480,7 @@ type RefreshTokensUserSetting_RefreshToken struct {
// When the token was created
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
// Client information for session management UI
ClientInfo *SessionsUserSetting_ClientInfo `protobuf:"bytes,4,opt,name=client_info,json=clientInfo,proto3" json:"client_info,omitempty"`
ClientInfo *RefreshTokensUserSetting_ClientInfo `protobuf:"bytes,4,opt,name=client_info,json=clientInfo,proto3" json:"client_info,omitempty"`
// Optional description
Description string `protobuf:"bytes,5,opt,name=description,proto3" json:"description,omitempty"`
unknownFields protoimpl.UnknownFields
@ -826,7 +489,7 @@ type RefreshTokensUserSetting_RefreshToken struct {
func (x *RefreshTokensUserSetting_RefreshToken) Reset() {
*x = RefreshTokensUserSetting_RefreshToken{}
mi := &file_store_user_setting_proto_msgTypes[11]
mi := &file_store_user_setting_proto_msgTypes[6]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -838,7 +501,7 @@ func (x *RefreshTokensUserSetting_RefreshToken) String() string {
func (*RefreshTokensUserSetting_RefreshToken) ProtoMessage() {}
func (x *RefreshTokensUserSetting_RefreshToken) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[11]
mi := &file_store_user_setting_proto_msgTypes[6]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -851,7 +514,7 @@ func (x *RefreshTokensUserSetting_RefreshToken) ProtoReflect() protoreflect.Mess
// Deprecated: Use RefreshTokensUserSetting_RefreshToken.ProtoReflect.Descriptor instead.
func (*RefreshTokensUserSetting_RefreshToken) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{4, 0}
return file_store_user_setting_proto_rawDescGZIP(), []int{2, 0}
}
func (x *RefreshTokensUserSetting_RefreshToken) GetTokenId() string {
@ -875,7 +538,7 @@ func (x *RefreshTokensUserSetting_RefreshToken) GetCreatedAt() *timestamppb.Time
return nil
}
func (x *RefreshTokensUserSetting_RefreshToken) GetClientInfo() *SessionsUserSetting_ClientInfo {
func (x *RefreshTokensUserSetting_RefreshToken) GetClientInfo() *RefreshTokensUserSetting_ClientInfo {
if x != nil {
return x.ClientInfo
}
@ -889,6 +552,87 @@ func (x *RefreshTokensUserSetting_RefreshToken) GetDescription() string {
return ""
}
type RefreshTokensUserSetting_ClientInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
// User agent string of the client.
UserAgent string `protobuf:"bytes,1,opt,name=user_agent,json=userAgent,proto3" json:"user_agent,omitempty"`
// IP address of the client.
IpAddress string `protobuf:"bytes,2,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"`
// Optional. Device type (e.g., "mobile", "desktop", "tablet").
DeviceType string `protobuf:"bytes,3,opt,name=device_type,json=deviceType,proto3" json:"device_type,omitempty"`
// Optional. Operating system (e.g., "iOS 17.0", "Windows 11").
Os string `protobuf:"bytes,4,opt,name=os,proto3" json:"os,omitempty"`
// Optional. Browser name and version (e.g., "Chrome 119.0").
Browser string `protobuf:"bytes,5,opt,name=browser,proto3" json:"browser,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *RefreshTokensUserSetting_ClientInfo) Reset() {
*x = RefreshTokensUserSetting_ClientInfo{}
mi := &file_store_user_setting_proto_msgTypes[7]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *RefreshTokensUserSetting_ClientInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RefreshTokensUserSetting_ClientInfo) ProtoMessage() {}
func (x *RefreshTokensUserSetting_ClientInfo) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[7]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use RefreshTokensUserSetting_ClientInfo.ProtoReflect.Descriptor instead.
func (*RefreshTokensUserSetting_ClientInfo) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{2, 1}
}
func (x *RefreshTokensUserSetting_ClientInfo) GetUserAgent() string {
if x != nil {
return x.UserAgent
}
return ""
}
func (x *RefreshTokensUserSetting_ClientInfo) GetIpAddress() string {
if x != nil {
return x.IpAddress
}
return ""
}
func (x *RefreshTokensUserSetting_ClientInfo) GetDeviceType() string {
if x != nil {
return x.DeviceType
}
return ""
}
func (x *RefreshTokensUserSetting_ClientInfo) GetOs() string {
if x != nil {
return x.Os
}
return ""
}
func (x *RefreshTokensUserSetting_ClientInfo) GetBrowser() string {
if x != nil {
return x.Browser
}
return ""
}
type PersonalAccessTokensUserSetting_PersonalAccessToken struct {
state protoimpl.MessageState `protogen:"open.v1"`
// Unique identifier for this token
@ -909,7 +653,7 @@ type PersonalAccessTokensUserSetting_PersonalAccessToken struct {
func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) Reset() {
*x = PersonalAccessTokensUserSetting_PersonalAccessToken{}
mi := &file_store_user_setting_proto_msgTypes[12]
mi := &file_store_user_setting_proto_msgTypes[8]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -921,7 +665,7 @@ func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) String() string {
func (*PersonalAccessTokensUserSetting_PersonalAccessToken) ProtoMessage() {}
func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[12]
mi := &file_store_user_setting_proto_msgTypes[8]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -934,7 +678,7 @@ func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) ProtoReflect() pro
// Deprecated: Use PersonalAccessTokensUserSetting_PersonalAccessToken.ProtoReflect.Descriptor instead.
func (*PersonalAccessTokensUserSetting_PersonalAccessToken) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{5, 0}
return file_store_user_setting_proto_rawDescGZIP(), []int{3, 0}
}
func (x *PersonalAccessTokensUserSetting_PersonalAccessToken) GetTokenId() string {
@ -990,7 +734,7 @@ type ShortcutsUserSetting_Shortcut struct {
func (x *ShortcutsUserSetting_Shortcut) Reset() {
*x = ShortcutsUserSetting_Shortcut{}
mi := &file_store_user_setting_proto_msgTypes[13]
mi := &file_store_user_setting_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1002,7 +746,7 @@ func (x *ShortcutsUserSetting_Shortcut) String() string {
func (*ShortcutsUserSetting_Shortcut) ProtoMessage() {}
func (x *ShortcutsUserSetting_Shortcut) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[13]
mi := &file_store_user_setting_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1015,7 +759,7 @@ func (x *ShortcutsUserSetting_Shortcut) ProtoReflect() protoreflect.Message {
// Deprecated: Use ShortcutsUserSetting_Shortcut.ProtoReflect.Descriptor instead.
func (*ShortcutsUserSetting_Shortcut) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{6, 0}
return file_store_user_setting_proto_rawDescGZIP(), []int{4, 0}
}
func (x *ShortcutsUserSetting_Shortcut) GetId() string {
@ -1053,7 +797,7 @@ type WebhooksUserSetting_Webhook struct {
func (x *WebhooksUserSetting_Webhook) Reset() {
*x = WebhooksUserSetting_Webhook{}
mi := &file_store_user_setting_proto_msgTypes[14]
mi := &file_store_user_setting_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -1065,7 +809,7 @@ func (x *WebhooksUserSetting_Webhook) String() string {
func (*WebhooksUserSetting_Webhook) ProtoMessage() {}
func (x *WebhooksUserSetting_Webhook) ProtoReflect() protoreflect.Message {
mi := &file_store_user_setting_proto_msgTypes[14]
mi := &file_store_user_setting_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -1078,7 +822,7 @@ func (x *WebhooksUserSetting_Webhook) ProtoReflect() protoreflect.Message {
// Deprecated: Use WebhooksUserSetting_Webhook.ProtoReflect.Descriptor instead.
func (*WebhooksUserSetting_Webhook) Descriptor() ([]byte, []int) {
return file_store_user_setting_proto_rawDescGZIP(), []int{7, 0}
return file_store_user_setting_proto_rawDescGZIP(), []int{5, 0}
}
func (x *WebhooksUserSetting_Webhook) GetId() string {
@ -1106,22 +850,18 @@ var File_store_user_setting_proto protoreflect.FileDescriptor
const file_store_user_setting_proto_rawDesc = "" +
"\n" +
"\x18store/user_setting.proto\x12\vmemos.store\x1a\x1fgoogle/protobuf/timestamp.proto\"\xfa\x05\n" +
"\x18store/user_setting.proto\x12\vmemos.store\x1a\x1fgoogle/protobuf/timestamp.proto\"\xcb\x04\n" +
"\vUserSetting\x12\x17\n" +
"\auser_id\x18\x01 \x01(\x05R\x06userId\x12.\n" +
"\x03key\x18\x02 \x01(\x0e2\x1c.memos.store.UserSetting.KeyR\x03key\x12;\n" +
"\ageneral\x18\x03 \x01(\v2\x1f.memos.store.GeneralUserSettingH\x00R\ageneral\x12>\n" +
"\bsessions\x18\x04 \x01(\v2 .memos.store.SessionsUserSettingH\x00R\bsessions\x12K\n" +
"\raccess_tokens\x18\x05 \x01(\v2$.memos.store.AccessTokensUserSettingH\x00R\faccessTokens\x12A\n" +
"\ageneral\x18\x03 \x01(\v2\x1f.memos.store.GeneralUserSettingH\x00R\ageneral\x12A\n" +
"\tshortcuts\x18\x06 \x01(\v2!.memos.store.ShortcutsUserSettingH\x00R\tshortcuts\x12>\n" +
"\bwebhooks\x18\a \x01(\v2 .memos.store.WebhooksUserSettingH\x00R\bwebhooks\x12N\n" +
"\x0erefresh_tokens\x18\b \x01(\v2%.memos.store.RefreshTokensUserSettingH\x00R\rrefreshTokens\x12d\n" +
"\x16personal_access_tokens\x18\t \x01(\v2,.memos.store.PersonalAccessTokensUserSettingH\x00R\x14personalAccessTokens\"\x95\x01\n" +
"\x16personal_access_tokens\x18\t \x01(\v2,.memos.store.PersonalAccessTokensUserSettingH\x00R\x14personalAccessTokens\"t\n" +
"\x03Key\x12\x13\n" +
"\x0fKEY_UNSPECIFIED\x10\x00\x12\v\n" +
"\aGENERAL\x10\x01\x12\f\n" +
"\bSESSIONS\x10\x02\x12\x11\n" +
"\rACCESS_TOKENS\x10\x03\x12\r\n" +
"\aGENERAL\x10\x01\x12\r\n" +
"\tSHORTCUTS\x10\x04\x12\f\n" +
"\bWEBHOOKS\x10\x05\x12\x12\n" +
"\x0eREFRESH_TOKENS\x10\x06\x12\x1a\n" +
@ -1130,17 +870,18 @@ const file_store_user_setting_proto_rawDesc = "" +
"\x12GeneralUserSetting\x12\x16\n" +
"\x06locale\x18\x01 \x01(\tR\x06locale\x12'\n" +
"\x0fmemo_visibility\x18\x02 \x01(\tR\x0ememoVisibility\x12\x14\n" +
"\x05theme\x18\x03 \x01(\tR\x05theme\"\xf3\x03\n" +
"\x13SessionsUserSetting\x12D\n" +
"\bsessions\x18\x01 \x03(\v2(.memos.store.SessionsUserSetting.SessionR\bsessions\x1a\xfd\x01\n" +
"\aSession\x12\x1d\n" +
"\x05theme\x18\x03 \x01(\tR\x05theme\"\xa4\x04\n" +
"\x18RefreshTokensUserSetting\x12Y\n" +
"\x0erefresh_tokens\x18\x01 \x03(\v22.memos.store.RefreshTokensUserSetting.RefreshTokenR\rrefreshTokens\x1a\x94\x02\n" +
"\fRefreshToken\x12\x19\n" +
"\btoken_id\x18\x01 \x01(\tR\atokenId\x129\n" +
"\n" +
"session_id\x18\x01 \x01(\tR\tsessionId\x12;\n" +
"\vcreate_time\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\n" +
"createTime\x12H\n" +
"\x12last_accessed_time\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\x10lastAccessedTime\x12L\n" +
"\vclient_info\x18\x04 \x01(\v2+.memos.store.SessionsUserSetting.ClientInfoR\n" +
"clientInfo\x1a\x95\x01\n" +
"expires_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x129\n" +
"\n" +
"created_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12Q\n" +
"\vclient_info\x18\x04 \x01(\v20.memos.store.RefreshTokensUserSetting.ClientInfoR\n" +
"clientInfo\x12 \n" +
"\vdescription\x18\x05 \x01(\tR\vdescription\x1a\x95\x01\n" +
"\n" +
"ClientInfo\x12\x1d\n" +
"\n" +
@ -1150,23 +891,7 @@ const file_store_user_setting_proto_rawDesc = "" +
"\vdevice_type\x18\x03 \x01(\tR\n" +
"deviceType\x12\x0e\n" +
"\x02os\x18\x04 \x01(\tR\x02os\x12\x18\n" +
"\abrowser\x18\x05 \x01(\tR\abrowser\"\xc4\x01\n" +
"\x17AccessTokensUserSetting\x12U\n" +
"\raccess_tokens\x18\x01 \x03(\v20.memos.store.AccessTokensUserSetting.AccessTokenR\faccessTokens\x1aR\n" +
"\vAccessToken\x12!\n" +
"\faccess_token\x18\x01 \x01(\tR\vaccessToken\x12 \n" +
"\vdescription\x18\x02 \x01(\tR\vdescription\"\x87\x03\n" +
"\x18RefreshTokensUserSetting\x12Y\n" +
"\x0erefresh_tokens\x18\x01 \x03(\v22.memos.store.RefreshTokensUserSetting.RefreshTokenR\rrefreshTokens\x1a\x8f\x02\n" +
"\fRefreshToken\x12\x19\n" +
"\btoken_id\x18\x01 \x01(\tR\atokenId\x129\n" +
"\n" +
"expires_at\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x129\n" +
"\n" +
"created_at\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12L\n" +
"\vclient_info\x18\x04 \x01(\v2+.memos.store.SessionsUserSetting.ClientInfoR\n" +
"clientInfo\x12 \n" +
"\vdescription\x18\x05 \x01(\tR\vdescription\"\xa3\x03\n" +
"\abrowser\x18\x05 \x01(\tR\abrowser\"\xa3\x03\n" +
"\x1fPersonalAccessTokensUserSetting\x12X\n" +
"\x06tokens\x18\x01 \x03(\v2@.memos.store.PersonalAccessTokensUserSetting.PersonalAccessTokenR\x06tokens\x1a\xa5\x02\n" +
"\x13PersonalAccessToken\x12\x19\n" +
@ -1207,55 +932,44 @@ func file_store_user_setting_proto_rawDescGZIP() []byte {
}
var file_store_user_setting_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
var file_store_user_setting_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_store_user_setting_proto_goTypes = []any{
(UserSetting_Key)(0), // 0: memos.store.UserSetting.Key
(*UserSetting)(nil), // 1: memos.store.UserSetting
(*GeneralUserSetting)(nil), // 2: memos.store.GeneralUserSetting
(*SessionsUserSetting)(nil), // 3: memos.store.SessionsUserSetting
(*AccessTokensUserSetting)(nil), // 4: memos.store.AccessTokensUserSetting
(*RefreshTokensUserSetting)(nil), // 5: memos.store.RefreshTokensUserSetting
(*PersonalAccessTokensUserSetting)(nil), // 6: memos.store.PersonalAccessTokensUserSetting
(*ShortcutsUserSetting)(nil), // 7: memos.store.ShortcutsUserSetting
(*WebhooksUserSetting)(nil), // 8: memos.store.WebhooksUserSetting
(*SessionsUserSetting_Session)(nil), // 9: memos.store.SessionsUserSetting.Session
(*SessionsUserSetting_ClientInfo)(nil), // 10: memos.store.SessionsUserSetting.ClientInfo
(*AccessTokensUserSetting_AccessToken)(nil), // 11: memos.store.AccessTokensUserSetting.AccessToken
(*RefreshTokensUserSetting_RefreshToken)(nil), // 12: memos.store.RefreshTokensUserSetting.RefreshToken
(*PersonalAccessTokensUserSetting_PersonalAccessToken)(nil), // 13: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
(*ShortcutsUserSetting_Shortcut)(nil), // 14: memos.store.ShortcutsUserSetting.Shortcut
(*WebhooksUserSetting_Webhook)(nil), // 15: memos.store.WebhooksUserSetting.Webhook
(*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp
(*RefreshTokensUserSetting)(nil), // 3: memos.store.RefreshTokensUserSetting
(*PersonalAccessTokensUserSetting)(nil), // 4: memos.store.PersonalAccessTokensUserSetting
(*ShortcutsUserSetting)(nil), // 5: memos.store.ShortcutsUserSetting
(*WebhooksUserSetting)(nil), // 6: memos.store.WebhooksUserSetting
(*RefreshTokensUserSetting_RefreshToken)(nil), // 7: memos.store.RefreshTokensUserSetting.RefreshToken
(*RefreshTokensUserSetting_ClientInfo)(nil), // 8: memos.store.RefreshTokensUserSetting.ClientInfo
(*PersonalAccessTokensUserSetting_PersonalAccessToken)(nil), // 9: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
(*ShortcutsUserSetting_Shortcut)(nil), // 10: memos.store.ShortcutsUserSetting.Shortcut
(*WebhooksUserSetting_Webhook)(nil), // 11: memos.store.WebhooksUserSetting.Webhook
(*timestamppb.Timestamp)(nil), // 12: google.protobuf.Timestamp
}
var file_store_user_setting_proto_depIdxs = []int32{
0, // 0: memos.store.UserSetting.key:type_name -> memos.store.UserSetting.Key
2, // 1: memos.store.UserSetting.general:type_name -> memos.store.GeneralUserSetting
3, // 2: memos.store.UserSetting.sessions:type_name -> memos.store.SessionsUserSetting
4, // 3: memos.store.UserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting
7, // 4: memos.store.UserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting
8, // 5: memos.store.UserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting
5, // 6: memos.store.UserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting
6, // 7: memos.store.UserSetting.personal_access_tokens:type_name -> memos.store.PersonalAccessTokensUserSetting
9, // 8: memos.store.SessionsUserSetting.sessions:type_name -> memos.store.SessionsUserSetting.Session
11, // 9: memos.store.AccessTokensUserSetting.access_tokens:type_name -> memos.store.AccessTokensUserSetting.AccessToken
12, // 10: memos.store.RefreshTokensUserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting.RefreshToken
13, // 11: memos.store.PersonalAccessTokensUserSetting.tokens:type_name -> memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
14, // 12: memos.store.ShortcutsUserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting.Shortcut
15, // 13: memos.store.WebhooksUserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting.Webhook
16, // 14: memos.store.SessionsUserSetting.Session.create_time:type_name -> google.protobuf.Timestamp
16, // 15: memos.store.SessionsUserSetting.Session.last_accessed_time:type_name -> google.protobuf.Timestamp
10, // 16: memos.store.SessionsUserSetting.Session.client_info:type_name -> memos.store.SessionsUserSetting.ClientInfo
16, // 17: memos.store.RefreshTokensUserSetting.RefreshToken.expires_at:type_name -> google.protobuf.Timestamp
16, // 18: memos.store.RefreshTokensUserSetting.RefreshToken.created_at:type_name -> google.protobuf.Timestamp
10, // 19: memos.store.RefreshTokensUserSetting.RefreshToken.client_info:type_name -> memos.store.SessionsUserSetting.ClientInfo
16, // 20: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.expires_at:type_name -> google.protobuf.Timestamp
16, // 21: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.created_at:type_name -> google.protobuf.Timestamp
16, // 22: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.last_used_at:type_name -> google.protobuf.Timestamp
23, // [23:23] is the sub-list for method output_type
23, // [23:23] is the sub-list for method input_type
23, // [23:23] is the sub-list for extension type_name
23, // [23:23] is the sub-list for extension extendee
0, // [0:23] is the sub-list for field type_name
5, // 2: memos.store.UserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting
6, // 3: memos.store.UserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting
3, // 4: memos.store.UserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting
4, // 5: memos.store.UserSetting.personal_access_tokens:type_name -> memos.store.PersonalAccessTokensUserSetting
7, // 6: memos.store.RefreshTokensUserSetting.refresh_tokens:type_name -> memos.store.RefreshTokensUserSetting.RefreshToken
9, // 7: memos.store.PersonalAccessTokensUserSetting.tokens:type_name -> memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken
10, // 8: memos.store.ShortcutsUserSetting.shortcuts:type_name -> memos.store.ShortcutsUserSetting.Shortcut
11, // 9: memos.store.WebhooksUserSetting.webhooks:type_name -> memos.store.WebhooksUserSetting.Webhook
12, // 10: memos.store.RefreshTokensUserSetting.RefreshToken.expires_at:type_name -> google.protobuf.Timestamp
12, // 11: memos.store.RefreshTokensUserSetting.RefreshToken.created_at:type_name -> google.protobuf.Timestamp
8, // 12: memos.store.RefreshTokensUserSetting.RefreshToken.client_info:type_name -> memos.store.RefreshTokensUserSetting.ClientInfo
12, // 13: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.expires_at:type_name -> google.protobuf.Timestamp
12, // 14: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.created_at:type_name -> google.protobuf.Timestamp
12, // 15: memos.store.PersonalAccessTokensUserSetting.PersonalAccessToken.last_used_at:type_name -> google.protobuf.Timestamp
16, // [16:16] is the sub-list for method output_type
16, // [16:16] is the sub-list for method input_type
16, // [16:16] is the sub-list for extension type_name
16, // [16:16] is the sub-list for extension extendee
0, // [0:16] is the sub-list for field type_name
}
func init() { file_store_user_setting_proto_init() }
@ -1265,8 +979,6 @@ func file_store_user_setting_proto_init() {
}
file_store_user_setting_proto_msgTypes[0].OneofWrappers = []any{
(*UserSetting_General)(nil),
(*UserSetting_Sessions)(nil),
(*UserSetting_AccessTokens)(nil),
(*UserSetting_Shortcuts)(nil),
(*UserSetting_Webhooks)(nil),
(*UserSetting_RefreshTokens)(nil),
@ -1278,7 +990,7 @@ func file_store_user_setting_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_store_user_setting_proto_rawDesc), len(file_store_user_setting_proto_rawDesc)),
NumEnums: 1,
NumMessages: 15,
NumMessages: 11,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -11,10 +11,6 @@ message UserSetting {
KEY_UNSPECIFIED = 0;
// General user settings.
GENERAL = 1;
// User authentication sessions.
SESSIONS = 2;
// Access tokens for the user.
ACCESS_TOKENS = 3;
// The shortcuts of the user.
SHORTCUTS = 4;
// The webhooks of the user.
@ -30,8 +26,6 @@ message UserSetting {
Key key = 2;
oneof value {
GeneralUserSetting general = 3;
SessionsUserSetting sessions = 4;
AccessTokensUserSetting access_tokens = 5;
ShortcutsUserSetting shortcuts = 6;
WebhooksUserSetting webhooks = 7;
RefreshTokensUserSetting refresh_tokens = 8;
@ -49,17 +43,18 @@ message GeneralUserSetting {
string theme = 3;
}
message SessionsUserSetting {
message Session {
// Unique session identifier.
string session_id = 1;
// Timestamp when the session was created.
google.protobuf.Timestamp create_time = 2;
// Timestamp when the session was last accessed.
// Used for sliding expiration calculation (last_accessed_time + 2 weeks).
google.protobuf.Timestamp last_accessed_time = 3;
// Client information associated with this session.
message RefreshTokensUserSetting {
message RefreshToken {
// Unique identifier (matches 'tid' claim in JWT)
string token_id = 1;
// When the token expires
google.protobuf.Timestamp expires_at = 2;
// When the token was created
google.protobuf.Timestamp created_at = 3;
// Client information for session management UI
ClientInfo client_info = 4;
// Optional description
string description = 5;
}
message ClientInfo {
@ -75,33 +70,6 @@ message SessionsUserSetting {
string browser = 5;
}
repeated Session sessions = 1;
}
message AccessTokensUserSetting {
message AccessToken {
// The access token is a JWT token.
// Including expiration time, issuer, etc.
string access_token = 1;
// A description for the access token.
string description = 2;
}
repeated AccessToken access_tokens = 1;
}
message RefreshTokensUserSetting {
message RefreshToken {
// Unique identifier (matches 'tid' claim in JWT)
string token_id = 1;
// When the token expires
google.protobuf.Timestamp expires_at = 2;
// When the token was created
google.protobuf.Timestamp created_at = 3;
// Client information for session management UI
SessionsUserSetting.ClientInfo client_info = 4;
// Optional description
string description = 5;
}
repeated RefreshToken refresh_tokens = 1;
}

View File

@ -394,8 +394,8 @@ func (s *APIV1Service) fetchCurrentUser(ctx context.Context) (*store.User, error
// - See all active sessions with device details
// - Identify suspicious login attempts
// - Revoke specific sessions from unknown devices.
func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.SessionsUserSetting_ClientInfo {
clientInfo := &storepb.SessionsUserSetting_ClientInfo{}
func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.RefreshTokensUserSetting_ClientInfo {
clientInfo := &storepb.RefreshTokensUserSetting_ClientInfo{}
// Extract user agent from metadata if available
if md, ok := metadata.FromIncomingContext(ctx); ok {
@ -427,7 +427,7 @@ func (s *APIV1Service) extractClientInfo(ctx context.Context) *storepb.SessionsU
//
// Note: This is a simplified parser. For production use with high accuracy requirements,
// consider using a dedicated user agent parsing library.
func (*APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.SessionsUserSetting_ClientInfo) {
func (*APIV1Service) parseUserAgent(userAgent string, clientInfo *storepb.RefreshTokensUserSetting_ClientInfo) {
if userAgent == "" {
return
}

View File

@ -72,7 +72,7 @@ func TestParseUserAgent(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
clientInfo := &storepb.SessionsUserSetting_ClientInfo{}
clientInfo := &storepb.RefreshTokensUserSetting_ClientInfo{}
service.parseUserAgent(tt.userAgent, clientInfo)
if clientInfo.DeviceType != tt.expectedDevice {
@ -155,7 +155,7 @@ func TestClientInfoExamples(t *testing.T) {
for _, example := range examples {
t.Run(example.description, func(t *testing.T) {
clientInfo := &storepb.SessionsUserSetting_ClientInfo{}
clientInfo := &storepb.RefreshTokensUserSetting_ClientInfo{}
service.parseUserAgent(example.userAgent, clientInfo)
t.Logf("User Agent: %s", example.userAgent)

View File

@ -175,22 +175,6 @@ func (s *ConnectServiceHandler) DeletePersonalAccessToken(ctx context.Context, r
return connect.NewResponse(resp), nil
}
func (s *ConnectServiceHandler) ListSessions(ctx context.Context, req *connect.Request[v1pb.ListSessionsRequest]) (*connect.Response[v1pb.ListSessionsResponse], error) {
resp, err := s.APIV1Service.ListSessions(ctx, req.Msg)
if err != nil {
return nil, convertGRPCError(err)
}
return connect.NewResponse(resp), nil
}
func (s *ConnectServiceHandler) RevokeSession(ctx context.Context, req *connect.Request[v1pb.RevokeSessionRequest]) (*connect.Response[emptypb.Empty], error) {
resp, err := s.APIV1Service.RevokeSession(ctx, req.Msg)
if err != nil {
return nil, convertGRPCError(err)
}
return connect.NewResponse(resp), nil
}
func (s *ConnectServiceHandler) ListUserWebhooks(ctx context.Context, req *connect.Request[v1pb.ListUserWebhooksRequest]) (*connect.Response[v1pb.ListUserWebhooksResponse], error) {
resp, err := s.APIV1Service.ListUserWebhooks(ctx, req.Msg)
if err != nil {

View File

@ -655,82 +655,6 @@ func (s *APIV1Service) DeletePersonalAccessToken(ctx context.Context, request *v
return &emptypb.Empty{}, nil
}
// ListSessions returns all active login sessions for a user.
// Each session represents a device/browser where the user is logged in,
// backed by refresh tokens with sliding expiration.
func (s *APIV1Service) ListSessions(ctx context.Context, request *v1pb.ListSessionsRequest) (*v1pb.ListSessionsResponse, error) {
userID, err := ExtractUserIDFromName(request.Parent)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid user name: %v", err)
}
// Verify permission.
claims := auth.GetUserClaims(ctx)
if claims == nil || claims.UserID != userID {
currentUser, _ := s.fetchCurrentUser(ctx)
if currentUser == nil || (currentUser.ID != userID && currentUser.Role != store.RoleHost && currentUser.Role != store.RoleAdmin) {
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
}
}
refreshTokens, err := s.Store.GetUserRefreshTokens(ctx, userID)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get sessions: %v", err)
}
sessions := make([]*v1pb.Session, 0, len(refreshTokens))
for _, token := range refreshTokens {
session := &v1pb.Session{
Name: fmt.Sprintf("%s/sessions/%s", request.Parent, token.TokenId),
SessionId: token.TokenId,
CreateTime: token.CreatedAt,
}
if token.ClientInfo != nil {
session.ClientInfo = &v1pb.Session_ClientInfo{
UserAgent: token.ClientInfo.UserAgent,
IpAddress: token.ClientInfo.IpAddress,
DeviceType: token.ClientInfo.DeviceType,
Os: token.ClientInfo.Os,
Browser: token.ClientInfo.Browser,
}
}
sessions = append(sessions, session)
}
return &v1pb.ListSessionsResponse{Sessions: sessions}, nil
}
// RevokeSession revokes a specific login session.
// This invalidates the refresh token, forcing re-authentication on that device.
func (s *APIV1Service) RevokeSession(ctx context.Context, request *v1pb.RevokeSessionRequest) (*emptypb.Empty, error) {
// Parse name: users/{user_id}/sessions/{session_id}
parts := strings.Split(request.Name, "/")
if len(parts) != 4 || parts[0] != "users" || parts[2] != "sessions" {
return nil, status.Errorf(codes.InvalidArgument, "invalid session name")
}
userID, err := util.ConvertStringToInt32(parts[1])
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "invalid user ID: %v", err)
}
sessionID := parts[3]
// Verify permission.
claims := auth.GetUserClaims(ctx)
if claims == nil || claims.UserID != userID {
currentUser, _ := s.fetchCurrentUser(ctx)
if currentUser == nil || (currentUser.ID != userID && currentUser.Role != store.RoleHost && currentUser.Role != store.RoleAdmin) {
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
}
}
if err := s.Store.RemoveUserRefreshToken(ctx, userID, sessionID); err != nil {
return nil, status.Errorf(codes.Internal, "failed to revoke session: %v", err)
}
return &emptypb.Empty{}, nil
}
func (s *APIV1Service) ListUserWebhooks(ctx context.Context, request *v1pb.ListUserWebhooksRequest) (*v1pb.ListUserWebhooksResponse, error) {
userID, err := ExtractUserIDFromName(request.Parent)
if err != nil {

View File

@ -401,18 +401,6 @@ func convertUserSettingFromRaw(raw *UserSetting) (*storepb.UserSetting, error) {
}
switch raw.Key {
case storepb.UserSetting_ACCESS_TOKENS:
accessTokensUserSetting := &storepb.AccessTokensUserSetting{}
if err := protojsonUnmarshaler.Unmarshal([]byte(raw.Value), accessTokensUserSetting); err != nil {
return nil, err
}
userSetting.Value = &storepb.UserSetting_AccessTokens{AccessTokens: accessTokensUserSetting}
case storepb.UserSetting_SESSIONS:
sessionsUserSetting := &storepb.SessionsUserSetting{}
if err := protojsonUnmarshaler.Unmarshal([]byte(raw.Value), sessionsUserSetting); err != nil {
return nil, err
}
userSetting.Value = &storepb.UserSetting_Sessions{Sessions: sessionsUserSetting}
case storepb.UserSetting_SHORTCUTS:
shortcutsUserSetting := &storepb.ShortcutsUserSetting{}
if err := protojsonUnmarshaler.Unmarshal([]byte(raw.Value), shortcutsUserSetting); err != nil {
@ -456,20 +444,6 @@ func convertUserSettingToRaw(userSetting *storepb.UserSetting) (*UserSetting, er
}
switch userSetting.Key {
case storepb.UserSetting_ACCESS_TOKENS:
accessTokensUserSetting := userSetting.GetAccessTokens()
value, err := protojson.Marshal(accessTokensUserSetting)
if err != nil {
return nil, err
}
raw.Value = string(value)
case storepb.UserSetting_SESSIONS:
sessionsUserSetting := userSetting.GetSessions()
value, err := protojson.Marshal(sessionsUserSetting)
if err != nil {
return nil, err
}
raw.Value = string(value)
case storepb.UserSetting_SHORTCUTS:
shortcutsUserSetting := userSetting.GetShortcuts()
value, err := protojson.Marshal(shortcutsUserSetting)

View File

@ -10,7 +10,6 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
import AccessTokenSection from "./AccessTokenSection";
import SettingGroup from "./SettingGroup";
import SettingSection from "./SettingSection";
import UserSessionsSection from "./UserSessionsSection";
const MyAccountSection = () => {
const t = useTranslate();
@ -57,10 +56,6 @@ const MyAccountSection = () => {
</div>
</SettingGroup>
<SettingGroup showSeparator>
<UserSessionsSection />
</SettingGroup>
<SettingGroup showSeparator>
<AccessTokenSection />
</SettingGroup>

View File

@ -1,165 +0,0 @@
import { timestampDate } from "@bufbuild/protobuf/wkt";
import { ClockIcon, MonitorIcon, SmartphoneIcon, TabletIcon, TrashIcon, WifiIcon } from "lucide-react";
import { useEffect, useState } from "react";
import { toast } from "react-hot-toast";
import ConfirmDialog from "@/components/ConfirmDialog";
import { Button } from "@/components/ui/button";
import { userServiceClient } from "@/connect";
import useCurrentUser from "@/hooks/useCurrentUser";
import { Session } from "@/types/proto/api/v1/user_service_pb";
import { useTranslate } from "@/utils/i18n";
import SettingTable from "./SettingTable";
const listSessions = async (parent: string) => {
const { sessions } = await userServiceClient.listSessions({ parent });
return sessions.sort(
(a, b) =>
((b.lastAccessedTime ? timestampDate(b.lastAccessedTime) : undefined)?.getTime() ?? 0) -
((a.lastAccessedTime ? timestampDate(a.lastAccessedTime) : undefined)?.getTime() ?? 0),
);
};
const UserSessionsSection = () => {
const t = useTranslate();
const currentUser = useCurrentUser();
const [sessions, setSessions] = useState<Session[]>([]);
const [revokeTarget, setRevokeTarget] = useState<Session | undefined>(undefined);
useEffect(() => {
listSessions(currentUser.name).then((sessions) => {
setSessions(sessions);
});
}, []);
const handleRevokeSession = async (session: Session) => {
setRevokeTarget(session);
};
const confirmRevokeSession = async () => {
if (!revokeTarget) return;
await userServiceClient.revokeSession({ name: revokeTarget.name });
setSessions(sessions.filter((session) => session.sessionId !== revokeTarget.sessionId));
toast.success(t("setting.user-sessions-section.session-revoked"));
setRevokeTarget(undefined);
};
const getFormattedSessionId = (sessionId: string) => {
return `${sessionId.slice(0, 8)}...${sessionId.slice(-8)}`;
};
const getDeviceIcon = (deviceType: string) => {
switch (deviceType?.toLowerCase()) {
case "mobile":
return <SmartphoneIcon className="w-4 h-4 text-muted-foreground" />;
case "tablet":
return <TabletIcon className="w-4 h-4 text-muted-foreground" />;
case "desktop":
default:
return <MonitorIcon className="w-4 h-4 text-muted-foreground" />;
}
};
const formatDeviceInfo = (clientInfo: Session["clientInfo"]) => {
if (!clientInfo) return "Unknown Device";
const parts = [];
if (clientInfo.os) parts.push(clientInfo.os);
if (clientInfo.browser) parts.push(clientInfo.browser);
return parts.length > 0 ? parts.join(" • ") : "Unknown Device";
};
const isCurrentSession = (session: Session) => {
// A simple heuristic: the most recently accessed session is likely the current one
if (sessions.length === 0) return false;
const mostRecent = sessions[0];
return session.sessionId === mostRecent.sessionId;
};
return (
<div className="w-full flex flex-col gap-2">
<div className="flex flex-col gap-1">
<h4 className="text-sm font-medium text-muted-foreground">{t("setting.user-sessions-section.title")}</h4>
<p className="text-xs text-muted-foreground">{t("setting.user-sessions-section.description")}</p>
</div>
<SettingTable
columns={[
{
key: "device",
header: t("setting.user-sessions-section.device"),
render: (_, session: Session) => (
<div className="flex items-center space-x-3">
{getDeviceIcon(session.clientInfo?.deviceType || "")}
<div className="flex flex-col">
<span className="font-medium text-foreground">
{formatDeviceInfo(session.clientInfo)}
{isCurrentSession(session) && (
<span className="ml-2 inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-primary/20 text-primary">
<WifiIcon className="w-3 h-3 mr-1" />
{t("setting.user-sessions-section.current")}
</span>
)}
</span>
<span className="text-xs text-muted-foreground font-mono">{getFormattedSessionId(session.sessionId)}</span>
</div>
</div>
),
},
{
key: "lastAccessedTime",
header: t("setting.user-sessions-section.last-active"),
render: (_, session: Session) => (
<div className="flex items-center space-x-1">
<ClockIcon className="w-4 h-4" />
<span>{(session.lastAccessedTime ? timestampDate(session.lastAccessedTime) : undefined)?.toLocaleString()}</span>
</div>
),
},
{
key: "actions",
header: "",
className: "text-right",
render: (_, session: Session) => (
<Button
variant="ghost"
size="sm"
disabled={isCurrentSession(session)}
onClick={() => handleRevokeSession(session)}
title={
isCurrentSession(session)
? t("setting.user-sessions-section.cannot-revoke-current")
: t("setting.user-sessions-section.revoke-session")
}
>
<TrashIcon className={`w-4 h-auto ${isCurrentSession(session) ? "text-muted-foreground" : "text-destructive"}`} />
</Button>
),
},
]}
data={sessions}
emptyMessage={t("setting.user-sessions-section.no-sessions")}
getRowKey={(session) => session.sessionId}
/>
<ConfirmDialog
open={!!revokeTarget}
onOpenChange={(open) => !open && setRevokeTarget(undefined)}
title={
revokeTarget
? t("setting.user-sessions-section.session-revocation", {
sessionId: getFormattedSessionId(revokeTarget.sessionId),
})
: ""
}
description={revokeTarget ? t("setting.user-sessions-section.session-revocation-description") : ""}
confirmLabel={t("setting.user-sessions-section.revoke-session-button")}
cancelLabel={t("common.cancel")}
onConfirm={confirmRevokeSession}
confirmVariant="destructive"
/>
</div>
);
};
export default UserSessionsSection;

View File

@ -251,21 +251,6 @@
"title": "رموز الوصول",
"token": "رمز"
},
"user-sessions-section": {
"title": "الجلسات النشطة",
"description": "قائمة بجميع الجلسات النشطة لحسابك. تنتهي الجلسات تلقائيًا بعد أسبوعين من آخر نشاط. يمكنك إلغاء أي جلسة باستثناء الحالية.",
"device": "الجهاز",
"location": "الموقع",
"last-active": "آخر نشاط",
"expires": "ينتهي",
"current": "الحالية",
"never": "أبدًا",
"session-revocation": "هل أنت متأكد من إلغاء الجلسة {{sessionId}}؟ ستحتاج إلى تسجيل الدخول مرة أخرى على ذلك الجهاز.",
"session-revoked": "تم إلغاء الجلسة بنجاح",
"revoke-session": "إلغاء الجلسة",
"cannot-revoke-current": "لا يمكن إلغاء الجلسة الحالية",
"no-sessions": "لا توجد جلسات نشطة"
},
"account-section": {
"change-password": "تغيير كلمة المرور",
"email-note": "اختياري",

View File

@ -251,21 +251,6 @@
"title": "Tokens d'accés",
"token": "Token"
},
"user-sessions-section": {
"title": "Sessions actives",
"description": "Llista de totes les sessions actives del teu compte. Les sessions caduquen automàticament dues setmanes després de l'última activitat. Pots revocar qualsevol sessió excepte la sessió actual.",
"device": "Dispositiu",
"location": "Ubicació",
"last-active": "Última activitat",
"expires": "Caduca",
"current": "Actual",
"never": "Mai",
"session-revocation": "Estàs segur que vols revocar la sessió {{sessionId}}? Hauràs d'iniciar sessió de nou en aquest dispositiu.",
"session-revoked": "Sessió revocada correctament",
"revoke-session": "Revoca la sessió",
"cannot-revoke-current": "No es pot revocar la sessió actual",
"no-sessions": "No s'han trobat sessions actives"
},
"account-section": {
"change-password": "Canvia la contrasenya",
"email-note": "Opcional",

View File

@ -236,21 +236,6 @@
"title": "Zugangstoken",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktive Sitzungen",
"description": "Liste aller aktiven Sitzungen für deinen Account. Sitzungen laufen automatisch 2 Wochen nach der letzten Aktivität ab. Du kannst jede Sitzung außer der aktuellen widerrufen.",
"device": "Gerät",
"location": "Standort",
"last-active": "Zuletzt aktiv",
"expires": "Läuft ab",
"current": "Aktuell",
"never": "Nie",
"session-revocation": "Bist du sicher, dass du die Sitzung {{sessionId}} widerrufen möchtest? Du musst dich auf diesem Gerät erneut anmelden.",
"session-revoked": "Sitzung erfolgreich widerrufen",
"revoke-session": "Sitzung widerrufen",
"cannot-revoke-current": "Aktuelle Sitzung kann nicht widerrufen werden",
"no-sessions": "Keine aktiven Sitzungen gefunden"
},
"account-section": {
"change-password": "Passwort ändern",
"email-note": "Optional",

View File

@ -272,23 +272,6 @@
"title": "Access Tokens",
"token": "Token"
},
"user-sessions-section": {
"title": "Active Sessions",
"description": "A list of all active sessions for your account. Sessions automatically expire 2 weeks after the last activity. You can revoke any session except the current one.",
"device": "Device",
"location": "Location",
"last-active": "Last Active",
"expires": "Expires",
"current": "Current",
"never": "Never",
"session-revocation": "Are you sure you want to revoke session `{{sessionId}}`?",
"session-revocation-description": "You will need to sign in again on that device.",
"session-revoked": "Session revoked successfully",
"revoke-session": "Revoke session",
"revoke-session-button": "Revoke",
"cannot-revoke-current": "Cannot revoke current session",
"no-sessions": "No active sessions found"
},
"account-section": {
"change-password": "Change password",
"email-note": "Optional",

View File

@ -247,21 +247,6 @@
"title": "Tokens de acceso",
"token": "Token"
},
"user-sessions-section": {
"title": "Sesiones activas",
"description": "Lista de todas las sesiones activas de tu cuenta. Las sesiones expiran automáticamente 2 semanas después de la última actividad. Puedes revocar cualquier sesión excepto la actual.",
"device": "Dispositivo",
"location": "Ubicación",
"last-active": "Última actividad",
"expires": "Expira",
"current": "Actual",
"never": "Nunca",
"session-revocation": "¿Estás seguro de revocar la sesión {{sessionId}}? Deberás iniciar sesión de nuevo en ese dispositivo.",
"session-revoked": "Sesión revocada correctamente",
"revoke-session": "Revocar sesión",
"cannot-revoke-current": "No se puede revocar la sesión actual",
"no-sessions": "No se encontraron sesiones activas"
},
"account-section": {
"change-password": "Cambiar contraseña",
"email-note": "Opcional",

View File

@ -226,21 +226,6 @@
"title": "توکن‌های دسترسی",
"token": "توکن"
},
"user-sessions-section": {
"title": "نشست‌های فعال",
"description": "لیست تمام نشست‌های فعال حساب شما. نشست‌ها به طور خودکار دو هفته پس از آخرین فعالیت منقضی می‌شوند. می‌توانید هر نشستی به جز نشست فعلی را لغو کنید.",
"device": "دستگاه",
"location": "مکان",
"last-active": "آخرین فعالیت",
"expires": "منقضی می‌شود",
"current": "فعلی",
"never": "هرگز",
"session-revocation": "آیا از لغو نشست {{sessionId}} اطمینان دارید؟ باید دوباره در آن دستگاه وارد شوید.",
"session-revoked": "نشست با موفقیت لغو شد",
"revoke-session": "لغو نشست",
"cannot-revoke-current": "نشست فعلی را نمی‌توان لغو کرد",
"no-sessions": "نشست فعالی یافت نشد"
},
"account-section": {
"change-password": "تغییر گذرواژه",
"email-note": "اختیاری",

View File

@ -251,21 +251,6 @@
"title": "Jetons d'accès",
"token": "Jeton"
},
"user-sessions-section": {
"title": "Sessions actives",
"description": "Liste de toutes les sessions actives de votre compte. Les sessions expirent automatiquement 2 semaines après la dernière activité. Vous pouvez révoquer toute session sauf la session actuelle.",
"device": "Appareil",
"location": "Emplacement",
"last-active": "Dernière activité",
"expires": "Expire",
"current": "Actuelle",
"never": "Jamais",
"session-revocation": "Êtes-vous sûr de vouloir révoquer la session {{sessionId}} ? Vous devrez vous reconnecter sur cet appareil.",
"session-revoked": "Session révoquée avec succès",
"revoke-session": "Révoquer la session",
"cannot-revoke-current": "Impossible de révoquer la session actuelle",
"no-sessions": "Aucune session active trouvée"
},
"account-section": {
"change-password": "Changer le mot de passe",
"email-note": "Optionnel",

View File

@ -252,21 +252,6 @@
"title": "एक्सेस टोकन",
"token": "टोकन"
},
"user-sessions-section": {
"title": "सक्रिय सत्र",
"description": "आपके खाते के सभी सक्रिय सत्रों की सूची। सत्र अंतिम गतिविधि के 2 सप्ताह बाद स्वतः समाप्त हो जाते हैं। आप वर्तमान सत्र को छोड़कर किसी भी सत्र को रद्द कर सकते हैं।",
"device": "डिवाइस",
"location": "स्थान",
"last-active": "अंतिम सक्रिय",
"expires": "समाप्ति",
"current": "वर्तमान",
"never": "कभी नहीं",
"session-revocation": "क्या आप सत्र {{sessionId}} को रद्द करना चाहते हैं? आपको उस डिवाइस पर फिर से साइन इन करना होगा।",
"session-revoked": "सत्र सफलतापूर्वक रद्द किया गया",
"revoke-session": "सत्र रद्द करें",
"cannot-revoke-current": "वर्तमान सत्र को रद्द नहीं किया जा सकता",
"no-sessions": "कोई सक्रिय सत्र नहीं मिला"
},
"account-section": {
"change-password": "पासवर्ड बदलें",
"email-note": "वैकल्पिक",

View File

@ -251,21 +251,6 @@
"title": "Tokeni pristupa",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktivne sesije",
"description": "Popis svih aktivnih sesija za tvoj račun. Sesije automatski istječu 2 tjedna nakon zadnje aktivnosti. Možeš opozvati bilo koju sesiju osim trenutne.",
"device": "Uređaj",
"location": "Lokacija",
"last-active": "Zadnja aktivnost",
"expires": "Istječe",
"current": "Trenutna",
"never": "Nikada",
"session-revocation": "Jesi li siguran da želiš opozvati sesiju {{sessionId}}? Morat ćeš se ponovno prijaviti na tom uređaju.",
"session-revoked": "Sesija uspješno opozvana",
"revoke-session": "Opozovi sesiju",
"cannot-revoke-current": "Trenutna sesija se ne može opozvati",
"no-sessions": "Nema aktivnih sesija"
},
"account-section": {
"change-password": "Promijeni lozinku",
"email-note": "Neobavezno",

View File

@ -252,21 +252,6 @@
"title": "Hozzáférési tokenek",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktív munkamenetek",
"description": "A fiókodhoz tartozó összes aktív munkamenet listája. A munkamenetek automatikusan lejárnak az utolsó aktivitástól számított 2 hét után. A jelenlegi kivételével bármelyiket visszavonhatod.",
"device": "Eszköz",
"location": "Hely",
"last-active": "Utoljára aktív",
"expires": "Lejár",
"current": "Jelenlegi",
"never": "Soha",
"session-revocation": "Biztosan visszavonod a(z) {{sessionId}} munkamenetet? Újra be kell jelentkezned azon az eszközön.",
"session-revoked": "A munkamenet sikeresen visszavonva",
"revoke-session": "Munkamenet visszavonása",
"cannot-revoke-current": "A jelenlegi munkamenet nem vonható vissza",
"no-sessions": "Nincs aktív munkamenet"
},
"account-section": {
"change-password": "Jelszó megváltoztatása",
"email-note": "Nem kötelező",

View File

@ -251,21 +251,6 @@
"title": "Token Akses",
"token": "Token"
},
"user-sessions-section": {
"title": "Sesi Aktif",
"description": "Daftar semua sesi aktif untuk akun Anda. Sesi akan otomatis berakhir 2 minggu setelah aktivitas terakhir. Anda dapat mencabut sesi mana pun kecuali sesi saat ini.",
"device": "Perangkat",
"location": "Lokasi",
"last-active": "Terakhir Aktif",
"expires": "Berakhir",
"current": "Saat ini",
"never": "Tidak Pernah",
"session-revocation": "Apakah Anda yakin ingin mencabut sesi {{sessionId}}? Anda perlu masuk kembali di perangkat tersebut.",
"session-revoked": "Sesi berhasil dicabut",
"revoke-session": "Cabut sesi",
"cannot-revoke-current": "Tidak dapat mencabut sesi saat ini",
"no-sessions": "Tidak ada sesi aktif yang ditemukan"
},
"account-section": {
"change-password": "Ubah kata sandi",
"email-note": "Opsional",

View File

@ -270,23 +270,6 @@
"title": "Token di accesso",
"token": "Token"
},
"user-sessions-section": {
"title": "Sessioni attive",
"description": "Elenco di tutte le sessioni attive del tuo account. Le sessioni scadono automaticamente dopo 2 settimane dall'ultima attività. Puoi revocare qualsiasi sessione tranne quella attuale.",
"device": "Dispositivo",
"location": "Posizione",
"last-active": "Ultima attività",
"expires": "Scade",
"current": "Attuale",
"never": "Mai",
"session-revocation": "Confermi di voler revocare la sessione `{{sessionId}}`?",
"session-revocation-description": "Dovrai accedere di nuovo su quel dispositivo.",
"session-revoked": "Sessione revocata con successo",
"revoke-session": "Revoca sessione",
"revoke-session-button": "Revoca",
"cannot-revoke-current": "Impossibile revocare la sessione attuale",
"no-sessions": "Nessuna sessione attiva trovata"
},
"account-section": {
"change-password": "Cambia password",
"email-note": "Opzionale",

View File

@ -251,21 +251,6 @@
"title": "アクセストークン",
"token": "トークン"
},
"user-sessions-section": {
"title": "アクティブセッション",
"description": "あなたのアカウントのすべてのアクティブなセッション一覧です。セッションは最後の操作から2週間後に自動的に期限切れになります。現在のセッション以外は取り消し可能です。",
"device": "デバイス",
"location": "場所",
"last-active": "最終アクティブ",
"expires": "有効期限",
"current": "現在",
"never": "無期限",
"session-revocation": "セッション {{sessionId}} を取り消しますか?そのデバイスで再度サインインが必要です。",
"session-revoked": "セッションを取り消しました",
"revoke-session": "セッションを取り消す",
"cannot-revoke-current": "現在のセッションは取り消せません",
"no-sessions": "アクティブなセッションはありません"
},
"account-section": {
"change-password": "パスワードを変更",
"email-note": "オプション",

View File

@ -251,21 +251,6 @@
"title": "წვდომის ტოკენები",
"token": "ტოკენი"
},
"user-sessions-section": {
"title": "აქტიური სესიები",
"description": "თქვენი ანგარიშის ყველა აქტიური სესიის სია. სესიები ავტომატურად იწურება ბოლო აქტივობიდან 2 კვირის შემდეგ. შეგიძლიათ გააუქმოთ ნებისმიერი სესია გარდა მიმდინარე სესიისა.",
"device": "მოწყობილობა",
"location": "მდებარეობა",
"last-active": "ბოლო აქტიურობა",
"expires": "ვადა იწურება",
"current": "მიმდინარე",
"never": "არასდროს",
"session-revocation": "დარწმუნებული ხართ, რომ გსურთ სესიის გაუქმება {{sessionId}}? მოგიწევთ ხელახლა შესვლა ამ მოწყობილობაზე.",
"session-revoked": "სესია წარმატებით გაუქმდა",
"revoke-session": "სესიის გაუქმება",
"cannot-revoke-current": "მიმდინარე სესიის გაუქმება შეუძლებელია",
"no-sessions": "აქტიური სესიები ვერ მოიძებნა"
},
"account-section": {
"change-password": "პაროლის შეცვლა",
"email-note": "არასავალდებულო",

View File

@ -259,21 +259,6 @@
"title": "액세스 토큰",
"token": "토큰"
},
"user-sessions-section": {
"title": "활성 세션",
"description": "계정의 모든 활성 세션 목록입니다. 세션은 마지막 활동 후 2주 후에 자동으로 만료됩니다. 현재 세션을 제외한 모든 세션을 취소할 수 있습니다.",
"device": "기기",
"location": "위치",
"last-active": "마지막 활동",
"expires": "만료",
"current": "현재",
"never": "영구",
"session-revocation": "세션 {{sessionId}}을 취소하시겠습니까? 해당 기기에서 다시 로그인해야 합니다.",
"session-revoked": "세션이 성공적으로 취소되었습니다",
"revoke-session": "세션 취소",
"cannot-revoke-current": "현재 세션은 취소할 수 없습니다",
"no-sessions": "활성 세션이 없습니다"
},
"account-section": {
"change-password": "비밀번호 변경",
"email-note": "선택 사항",

View File

@ -251,21 +251,6 @@
"title": "ऍक्सेस टोकन्स",
"token": "टोकन"
},
"user-sessions-section": {
"title": "सक्रिय सत्रे",
"description": "तुमच्या खात्यातील सर्व सक्रिय सत्रांची यादी. सत्रे शेवटच्या क्रियेनंतर 2 आठवड्यांनी आपोआप कालबाह्य होतात. तुम्ही चालू सत्र वगळता कोणतेही सत्र रद्द करू शकता.",
"device": "डिव्हाइस",
"location": "स्थान",
"last-active": "शेवटचे सक्रिय",
"expires": "कालबाह्यता",
"current": "चालू",
"never": "कधीच नाही",
"session-revocation": "तुम्हाला सत्र {{sessionId}} रद्द करायचे आहे का? त्या डिव्हाइसवर पुन्हा साइन इन करावे लागेल.",
"session-revoked": "सत्र यशस्वीरित्या रद्द केले",
"revoke-session": "सत्र रद्द करा",
"cannot-revoke-current": "चालू सत्र रद्द करता येणार नाही",
"no-sessions": "कोणतीही सक्रिय सत्रे आढळली नाहीत"
},
"account-section": {
"change-password": "पासवर्ड बदला",
"email-note": "ऐच्छिक",

View File

@ -251,21 +251,6 @@
"title": "Access tokens",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktive økter",
"description": "En liste over alle aktive økter for din konto. Økter utløper automatisk 2 uker etter siste aktivitet. Du kan tilbakekalle enhver økt bortsett fra den nåværende.",
"device": "Enhet",
"location": "Plassering",
"last-active": "Sist aktiv",
"expires": "Utløper",
"current": "Nåværende",
"never": "Aldri",
"session-revocation": "Er du sikker på at du vil tilbakekalle økt {{sessionId}}? Du må logge inn på nytt på den enheten.",
"session-revoked": "Økt tilbakekalt",
"revoke-session": "Tilbakekall økt",
"cannot-revoke-current": "Kan ikke tilbakekalle nåværende økt",
"no-sessions": "Ingen aktive økter funnet"
},
"account-section": {
"change-password": "Endre passord",
"email-note": "Valgfritt",

View File

@ -251,21 +251,6 @@
"title": "Accesstokens",
"token": "Token"
},
"user-sessions-section": {
"title": "Actieve sessies",
"description": "Een lijst van alle actieve sessies voor je account. Sessies verlopen automatisch 2 weken na de laatste activiteit. Je kunt elke sessie intrekken behalve de huidige.",
"device": "Apparaat",
"location": "Locatie",
"last-active": "Laatst actief",
"expires": "Verloopt",
"current": "Huidig",
"never": "Nooit",
"session-revocation": "Weet je zeker dat je sessie {{sessionId}} wilt intrekken? Je moet opnieuw inloggen op dat apparaat.",
"session-revoked": "Sessie succesvol ingetrokken",
"revoke-session": "Sessie intrekken",
"cannot-revoke-current": "Kan huidige sessie niet intrekken",
"no-sessions": "Geen actieve sessies gevonden"
},
"account-section": {
"change-password": "Wachtwoord wijzigen",
"email-note": "Optioneel",

View File

@ -251,21 +251,6 @@
"title": "Tokeny dostępu",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktywne sesje",
"description": "Lista wszystkich aktywnych sesji Twojego konta. Sesje wygasają automatycznie po 2 tygodniach od ostatniej aktywności. Możesz cofnąć dowolną sesję oprócz bieżącej.",
"device": "Urządzenie",
"location": "Lokalizacja",
"last-active": "Ostatnia aktywność",
"expires": "Wygasa",
"current": "Bieżąca",
"never": "Nigdy",
"session-revocation": "Czy na pewno chcesz cofnąć sesję {{sessionId}}? Będziesz musiał zalogować się ponownie na tym urządzeniu.",
"session-revoked": "Sesja cofnięta pomyślnie",
"revoke-session": "Cofnij sesję",
"cannot-revoke-current": "Nie można cofnąć bieżącej sesji",
"no-sessions": "Nie znaleziono aktywnych sesji"
},
"account-section": {
"change-password": "Zmień hasło",
"email-note": "Opcjonalne",

View File

@ -251,21 +251,6 @@
"title": "Tokens de acesso",
"token": "Token"
},
"user-sessions-section": {
"title": "Sessões ativas",
"description": "Uma lista de todas as sessões ativas da sua conta. As sessões expiram automaticamente 2 semanas após a última atividade. Você pode revogar qualquer sessão, exceto a atual.",
"device": "Dispositivo",
"location": "Localização",
"last-active": "Última atividade",
"expires": "Expira",
"current": "Atual",
"never": "Nunca",
"session-revocation": "Tem certeza de que deseja revogar a sessão {{sessionId}}? Você precisará entrar novamente nesse dispositivo.",
"session-revoked": "Sessão revogada com sucesso",
"revoke-session": "Revogar sessão",
"cannot-revoke-current": "Não é possível revogar a sessão atual",
"no-sessions": "Nenhuma sessão ativa encontrada"
},
"account-section": {
"change-password": "Alterar senha",
"email-note": "Opcional",

View File

@ -251,21 +251,6 @@
"title": "Tokens de Acesso",
"token": "Token"
},
"user-sessions-section": {
"title": "Sessões ativas",
"description": "Uma lista de todas as sessões ativas da sua conta. As sessões expiram automaticamente 2 semanas após a última atividade. Pode revogar qualquer sessão exceto a atual.",
"device": "Dispositivo",
"location": "Localização",
"last-active": "Última atividade",
"expires": "Expira",
"current": "Atual",
"never": "Nunca",
"session-revocation": "Tem a certeza de que deseja revogar a sessão {{sessionId}}? Terá de iniciar sessão novamente nesse dispositivo.",
"session-revoked": "Sessão revogada com sucesso",
"revoke-session": "Revogar sessão",
"cannot-revoke-current": "Não é possível revogar a sessão atual",
"no-sessions": "Nenhuma sessão ativa encontrada"
},
"account-section": {
"change-password": "Alterar palavra-passe",
"email-note": "Opcional",

View File

@ -229,21 +229,6 @@
"title": "Токены доступа",
"token": "Токен"
},
"user-sessions-section": {
"title": "Активные сессии",
"description": "Список всех активных сессий для вашей учетной записи. Сессии истекают через 2 недели после последней активности. Вы можете завершить любую сессию, кроме текущей.",
"device": "Устройство",
"location": "Местоположение",
"last-active": "Последняя активность",
"expires": "Expires",
"current": "Текущая",
"never": "Никогда",
"session-revocation": "Вы действительно хотите завершить сессию {{sessionId}}?\nПридётся повторно войти на связанном устройстве.",
"session-revoked": "Сессия завершена",
"revoke-session": "Завершить сессию",
"cannot-revoke-current": "Нельзя завершить текущую сессию",
"no-sessions": "Нет активных сессий"
},
"account-section": {
"change-password": "Изменить пароль",
"email-note": "Опционально",

View File

@ -251,21 +251,6 @@
"title": "Dostopni žetoni",
"token": "Žeton"
},
"user-sessions-section": {
"title": "Aktivne seje",
"description": "Seznam vseh aktivnih sej vašega računa. Seje samodejno potečejo 2 tedna po zadnji aktivnosti. Lahko prekličete katerokoli sejo razen trenutne.",
"device": "Naprava",
"location": "Lokacija",
"last-active": "Zadnja aktivnost",
"expires": "Poteče",
"current": "Trenutna",
"never": "Nikoli",
"session-revocation": "Ali ste prepričani, da želite preklicati sejo {{sessionId}}? Ponovno se boste morali prijaviti na tej napravi.",
"session-revoked": "Seja uspešno preklicana",
"revoke-session": "Prekliči sejo",
"cannot-revoke-current": "Trenutne seje ni mogoče preklicati",
"no-sessions": "Ni aktivnih sej"
},
"account-section": {
"change-password": "Zamenjaj geslo",
"email-note": "Opcijsko",

View File

@ -251,21 +251,6 @@
"title": "Åtkomsttoken",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktiva sessioner",
"description": "En lista över alla aktiva sessioner för ditt konto. Sessioner upphör automatiskt 2 veckor efter senaste aktivitet. Du kan återkalla alla sessioner utom den nuvarande.",
"device": "Enhet",
"location": "Plats",
"last-active": "Senast aktiv",
"expires": "Går ut",
"current": "Nuvarande",
"never": "Aldrig",
"session-revocation": "Är du säker på att återkalla session {{sessionId}}? Du måste logga in igen på den enheten.",
"session-revoked": "Session återkallad",
"revoke-session": "Återkalla session",
"cannot-revoke-current": "Kan inte återkalla nuvarande session",
"no-sessions": "Inga aktiva sessioner hittades"
},
"account-section": {
"change-password": "Ändra lösenord",
"email-note": "Valfritt",

View File

@ -251,21 +251,6 @@
"title": "โทเค็นการเข้าถึง",
"token": "โทเค็น"
},
"user-sessions-section": {
"title": "เซสชันที่ใช้งานอยู่",
"description": "รายการเซสชันที่ใช้งานอยู่ทั้งหมดสำหรับบัญชีของคุณ เซสชันจะหมดอายุอัตโนมัติหลังจากไม่มีการใช้งาน 2 สัปดาห์ คุณสามารถเพิกถอนเซสชันใดก็ได้ยกเว้นเซสชันปัจจุบัน",
"device": "อุปกรณ์",
"location": "ตำแหน่ง",
"last-active": "ใช้งานล่าสุด",
"expires": "หมดอายุ",
"current": "ปัจจุบัน",
"never": "ไม่หมดอายุ",
"session-revocation": "คุณแน่ใจหรือว่าจะเพิกถอนเซสชัน {{sessionId}}? คุณจะต้องเข้าสู่ระบบใหม่บนอุปกรณ์นั้น",
"session-revoked": "เพิกถอนเซสชันสำเร็จ",
"revoke-session": "เพิกถอนเซสชัน",
"cannot-revoke-current": "ไม่สามารถเพิกถอนเซสชันปัจจุบันได้",
"no-sessions": "ไม่พบเซสชันที่ใช้งานอยู่"
},
"account-section": {
"change-password": "เปลี่ยนรหัสผ่าน",
"email-note": "ไม่บังคับ",

View File

@ -251,21 +251,6 @@
"title": "Erişim Tokenleri",
"token": "Token"
},
"user-sessions-section": {
"title": "Aktif Oturumlar",
"description": "Hesabınız için tüm aktif oturumların listesi. Oturumlar, son etkinlikten 2 hafta sonra otomatik olarak sona erer. Mevcut oturum hariç herhangi bir oturumu iptal edebilirsiniz.",
"device": "Cihaz",
"location": "Konum",
"last-active": "Son Etkinlik",
"expires": "Sona Erme",
"current": "Mevcut",
"never": "Asla",
"session-revocation": "{{sessionId}} oturumunu iptal etmek istediğinizden emin misiniz? O cihazda tekrar giriş yapmanız gerekecek.",
"session-revoked": "Oturum başarıyla iptal edildi",
"revoke-session": "Oturumu iptal et",
"cannot-revoke-current": "Mevcut oturum iptal edilemez",
"no-sessions": "Aktif oturum bulunamadı"
},
"account-section": {
"change-password": "Şifre değiştir",
"email-note": "İsteğe bağlı",

View File

@ -251,21 +251,6 @@
"title": "Токени доступу",
"token": "Токен"
},
"user-sessions-section": {
"title": "Активні сесії",
"description": "Список усіх активних сесій для вашого облікового запису. Сесії автоматично завершуються через 2 тижні після останньої активності. Ви можете відкликати будь-яку сесію, окрім поточної.",
"device": "Пристрій",
"location": "Місцезнаходження",
"last-active": "Остання активність",
"expires": "Завершується",
"current": "Поточна",
"never": "Ніколи",
"session-revocation": "Ви впевнені, що хочете відкликати сесію {{sessionId}}? Вам потрібно буде увійти знову на цьому пристрої.",
"session-revoked": "Сесію успішно відкликано",
"revoke-session": "Відкликати сесію",
"cannot-revoke-current": "Не можна відкликати поточну сесію",
"no-sessions": "Активних сесій не знайдено"
},
"account-section": {
"change-password": "Змінити пароль",
"email-note": "Необов'язково",

View File

@ -256,21 +256,6 @@
"title": "访问令牌",
"token": "令牌"
},
"user-sessions-section": {
"title": "用户会话",
"description": "当前账号下全部的会话,你可以撤销除当前会话以外的所有会话。",
"device": "设备",
"location": "位置",
"last-active": "最后活跃时间",
"expires": "过期时间",
"current": "当前设备",
"never": "从未",
"session-revocation": "您确定要撤销会话 {{sessionId}} 吗?删除后您将需要在该设备上再次登录。",
"session-revoked": "会话已成功撤销",
"revoke-session": "撤销会话",
"cannot-revoke-current": "无法撤销当前会话",
"no-sessions": "当前没有会话"
},
"account-section": {
"change-password": "修改密码",
"email-note": "可选",

View File

@ -260,23 +260,6 @@
"title": "存取令牌",
"token": "令牌"
},
"user-sessions-section": {
"title": "工作階段",
"description": "此處列出您帳號的所有工作階段。工作階段將於最後一次活動的兩週後自動過期。您可以撤銷除了現階段之外的所有工作階段。",
"device": "裝置",
"location": "位置",
"last-active": "最後活躍時間",
"expires": "過期時間",
"current": "當前裝置",
"never": "永不過期",
"session-revocation": "您確定要撤銷工作階段 `{{sessionId}}` 嗎?",
"session-revocation-description": "您需要在該裝置上重新登入。",
"session-revoked": "工作階段撤銷成功",
"revoke-session": "撤銷工作階段",
"revoke-session-button": "撤銷",
"cannot-revoke-current": "無法撤銷當前裝置的工作階段",
"no-sessions": "無工作階段"
},
"account-section": {
"change-password": "變更密碼",
"email-note": "選填",

View File

@ -9,10 +9,8 @@ import {
User,
UserNotification,
UserSetting,
UserSetting_AccessTokensSetting,
UserSetting_GeneralSetting,
UserSetting_Key,
UserSetting_SessionsSetting,
UserSetting_WebhooksSetting,
UserSettingSchema,
UserStats,
@ -31,8 +29,6 @@ function getSettingValue<T>(setting: UserSetting, caseType: string): T | undefin
class LocalState {
currentUser?: string;
userGeneralSetting?: UserSetting_GeneralSetting;
userSessionsSetting?: UserSetting_SessionsSetting;
userAccessTokensSetting?: UserSetting_AccessTokensSetting;
userWebhooksSetting?: UserSetting_WebhooksSetting;
shortcuts: Shortcut[] = [];
notifications: UserNotification[] = [];
@ -214,16 +210,10 @@ const userStore = (() => {
// Extract and store each setting type using the oneof pattern
const generalSetting = settings.find((s) => s.value.case === "generalSetting");
const sessionsSetting = settings.find((s) => s.value.case === "sessionsSetting");
const accessTokensSetting = settings.find((s) => s.value.case === "accessTokensSetting");
const webhooksSetting = settings.find((s) => s.value.case === "webhooksSetting");
state.setPartial({
userGeneralSetting: generalSetting ? getSettingValue<UserSetting_GeneralSetting>(generalSetting, "generalSetting") : undefined,
userSessionsSetting: sessionsSetting ? getSettingValue<UserSetting_SessionsSetting>(sessionsSetting, "sessionsSetting") : undefined,
userAccessTokensSetting: accessTokensSetting
? getSettingValue<UserSetting_AccessTokensSetting>(accessTokensSetting, "accessTokensSetting")
: undefined,
userWebhooksSetting: webhooksSetting ? getSettingValue<UserSetting_WebhooksSetting>(webhooksSetting, "webhooksSetting") : undefined,
shortcuts: shortcuts,
});
@ -390,8 +380,6 @@ export const logout = async () => {
userStore.state.setPartial({
currentUser: undefined,
userGeneralSetting: undefined,
userSessionsSetting: undefined,
userAccessTokensSetting: undefined,
userWebhooksSetting: undefined,
shortcuts: [],
notifications: [],

File diff suppressed because one or more lines are too long