syntax = "proto3";

package auth;

// PERBAIKAN: Tambahkan 'transport' dan hapus suffix '/auth' agar sesuai direktori import
option go_package = "gen/auth/v1;auth";

message LoginRequest {
    string username = 1;
    string password = 2;
}

message LoginResponse {
    string token = 1;
    string expires_at = 2;
    User user = 3;
}

message RegisterRequest {
  string username = 1;
  string email = 2;
  string password = 3;
  string full_name = 4;
  string role = 5;
}

message RegisterResponse {
  string id = 1;
  string username = 2;
  string email = 3;
  string full_name = 4;
}

message ValidateTokenRequest {
  string token = 1;
}

message ValidateTokenResponse {
  bool valid = 1;
  User user = 2;
}

message LogoutRequest {
  string token = 1;
}

message LogoutResponse {
  bool success = 1;
}

message User {
  string id = 1;
  string username = 2;
  string email = 3;
  string full_name = 4;
  string role = 5;
}

service AuthService {
    rpc Register (RegisterRequest) returns (RegisterResponse);
    rpc Login(LoginRequest) returns (LoginResponse);
    rpc ValidateToken (ValidateTokenRequest) returns (ValidateTokenResponse);
    rpc Logout (LogoutRequest) returns (LogoutResponse);
}