feat(nex-servers): add nex token get stub and start working on grpc server
This commit is contained in:
parent
37a3c60a7a
commit
02c46fca1d
10 changed files with 347 additions and 12 deletions
30
src/grpc/mod.rs
Normal file
30
src/grpc/mod.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use tonic::{async_trait, Request, Response, Status};
|
||||
use crate::grpc::grpc::{ExchangeTokenForUserDataRequest, GetNexDataRequest, GetNexDataResponse, GetNexPasswordRequest, GetNexPasswordResponse, GetUserDataRequest, GetUserDataResponse, UpdatePnidPermissionsRequest};
|
||||
use crate::Pool;
|
||||
|
||||
mod grpc {
|
||||
tonic::include_proto!("account");
|
||||
}
|
||||
|
||||
|
||||
pub struct AccountService(pub Pool);
|
||||
|
||||
#[async_trait]
|
||||
impl grpc::account_server::Account for AccountService{
|
||||
async fn exchange_token_for_user_data(&self, request: Request<ExchangeTokenForUserDataRequest>) -> Result<Response<GetUserDataResponse>, Status> {
|
||||
todo!()
|
||||
}
|
||||
async fn get_nex_data(&self, request: Request<GetNexDataRequest>) -> Result<Response<GetNexDataResponse>, Status> {
|
||||
todo!()
|
||||
}
|
||||
async fn get_nex_password(&self, request: Request<GetNexPasswordRequest>) -> Result<Response<GetNexPasswordResponse>, Status> {
|
||||
todo!()
|
||||
}
|
||||
async fn update_pnid_permissions(&self, request: Request<UpdatePnidPermissionsRequest>) -> Result<Response<()>, Status> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
async fn get_user_data(&self, request: Request<GetUserDataRequest>) -> Result<Response<GetUserDataResponse>, Status> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@ mod account;
|
|||
mod error;
|
||||
mod dsresponse;
|
||||
mod data_wrapper;
|
||||
mod grpc;
|
||||
|
||||
type Pool = sqlx::Pool<Postgres>;
|
||||
|
||||
|
|
@ -61,6 +62,7 @@ async fn launch() -> _ {
|
|||
nnid::email::validate,
|
||||
nnid::people::create_account,
|
||||
nnid::people::get_own_profile,
|
||||
nnid::oauth::generate_token::generate_token
|
||||
nnid::oauth::generate_token::generate_token,
|
||||
nnid::provider::get_nex_token,
|
||||
])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,3 +6,4 @@ pub mod email;
|
|||
pub mod oauth;
|
||||
mod pid_distribution;
|
||||
pub mod people;
|
||||
pub mod provider;
|
||||
|
|
|
|||
|
|
@ -117,8 +117,6 @@ pub async fn generate_token(pool: &State<Pool>, data: Form<TokenRequestData<'_>>
|
|||
|
||||
let access_token = TokenReturnData::new(user.pid, pool).await;
|
||||
|
||||
|
||||
|
||||
Ok(Xml(TokenRequestReturnData{
|
||||
access_token
|
||||
}))
|
||||
|
|
|
|||
20
src/nnid/provider.rs
Normal file
20
src/nnid/provider.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use std::net::Ipv4Addr;
|
||||
use std::str::FromStr;
|
||||
use rocket::get;
|
||||
use serde::Serialize;
|
||||
use crate::xml::Xml;
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename = "nex_token")]
|
||||
struct NexToken{
|
||||
host: Ipv4Addr,
|
||||
nex_password: String,
|
||||
pid: i32,
|
||||
port: u16,
|
||||
token: String
|
||||
}
|
||||
|
||||
#[get("/v1/api/provider/nex_token/@me?<game_server_id>")]
|
||||
pub async fn get_nex_token(game_server_id: String) -> Option<Xml<NexToken>>{
|
||||
None
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue