- Removed the API proxy middleware and integrated RPC routes for user authentication. - Implemented JWT token generation and validation in the authentication middleware. - Enhanced user registration and login processes with password hashing and token management. - Added new routes for user password reset and Google OAuth login. - Introduced health check endpoints for service monitoring. - Updated gRPC client methods for user management, including password updates. - Refactored utility functions for token handling and Redis interactions. - Improved type definitions for better TypeScript support.
135 lines
4.0 KiB
Protocol Buffer
135 lines
4.0 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package stream.User.v1;
|
|
|
|
option go_package = "stream/proto/gen/go/User/v1;Userv1";
|
|
import "google/protobuf/empty.proto";
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
service UserService {
|
|
// User CRUD
|
|
rpc GetUser(GetUserRequest) returns (GetUserResponse);
|
|
rpc GetUserByEmail(GetUserByEmailRequest) returns (GetUserResponse);
|
|
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
|
|
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
|
|
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
|
|
rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse);
|
|
rpc UpdateUserPassword(UpdateUserPasswordRequest) returns (google.protobuf.Empty);
|
|
|
|
// Preferences
|
|
rpc GetPreferences(GetPreferencesRequest) returns (GetPreferencesResponse);
|
|
rpc UpsertPreferences(UpsertPreferencesRequest) returns (UpsertPreferencesResponse);
|
|
}
|
|
|
|
// ─── User Messages ───────────────────────────────────────────────────────────
|
|
message UpdateUserPasswordRequest {
|
|
string id = 1;
|
|
string new_password = 2;
|
|
}
|
|
message GetUserRequest {
|
|
string id = 1;
|
|
}
|
|
|
|
message GetUserByEmailRequest {
|
|
string email = 1;
|
|
}
|
|
|
|
message GetUserResponse {
|
|
User user = 1;
|
|
}
|
|
|
|
message ListUsersRequest {
|
|
int32 page = 1;
|
|
int32 page_size = 2;
|
|
string role = 3; // optional filter
|
|
}
|
|
|
|
message ListUsersResponse {
|
|
repeated User users = 1;
|
|
int32 total = 2;
|
|
int32 page = 3;
|
|
int32 page_size = 4;
|
|
}
|
|
|
|
message CreateUserRequest {
|
|
string email = 1;
|
|
optional string username = 2;
|
|
optional string password = 3;
|
|
}
|
|
|
|
message CreateUserResponse {
|
|
User user = 1;
|
|
}
|
|
|
|
message UpdateUserRequest {
|
|
string id = 1;
|
|
optional string username = 2;
|
|
optional string avatar = 3;
|
|
optional string role = 4;
|
|
optional string plan_id = 5;
|
|
}
|
|
|
|
message UpdateUserResponse {
|
|
User user = 1;
|
|
}
|
|
|
|
message DeleteUserRequest {
|
|
string id = 1;
|
|
}
|
|
|
|
message DeleteUserResponse {
|
|
bool success = 1;
|
|
}
|
|
|
|
// ─── Preferences Messages ────────────────────────────────────────────────────
|
|
|
|
message GetPreferencesRequest {
|
|
string user_id = 1;
|
|
}
|
|
|
|
message GetPreferencesResponse {
|
|
Preferences preferences = 1;
|
|
}
|
|
|
|
message UpsertPreferencesRequest {
|
|
Preferences preferences = 1;
|
|
}
|
|
|
|
message UpsertPreferencesResponse {
|
|
Preferences preferences = 1;
|
|
}
|
|
|
|
// ─── Core Models ─────────────────────────────────────────────────────────────
|
|
|
|
message User {
|
|
string id = 1;
|
|
string email = 2;
|
|
string password = 3;
|
|
optional string username = 4;
|
|
optional string avatar = 5;
|
|
optional string role = 6;
|
|
optional string google_id = 7;
|
|
int64 storage_used = 8;
|
|
optional string plan_id = 9;
|
|
optional google.protobuf.Timestamp created_at = 10;
|
|
google.protobuf.Timestamp updated_at = 11;
|
|
}
|
|
|
|
message Preferences {
|
|
string user_id = 1;
|
|
optional string language = 2;
|
|
optional string locale = 3;
|
|
optional bool email_notifications = 4;
|
|
optional bool push_notifications = 5;
|
|
optional bool marketing_notifications = 6;
|
|
optional bool telegram_notifications = 7;
|
|
optional bool autoplay = 8;
|
|
optional bool loop = 9;
|
|
optional bool muted = 10;
|
|
optional bool show_controls = 11;
|
|
optional bool pip = 12;
|
|
optional bool airplay = 13;
|
|
optional bool chromecast = 14;
|
|
optional bool encrytion_m3u8 = 15;
|
|
}
|