feat: add json api token generation
This commit is contained in:
parent
1935b8f6c4
commit
a267fbd5e3
4 changed files with 18 additions and 0 deletions
1
src/json_api/mod.rs
Normal file
1
src/json_api/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod oauth;
|
||||
14
src/json_api/oauth/generate_token.rs
Normal file
14
src/json_api/oauth/generate_token.rs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use rocket::{get, State};
|
||||
use crate::account::account::Auth;
|
||||
use crate::nnid::oauth::generate_token::create_token;
|
||||
use crate::nnid::oauth::generate_token::token_type::AUTH_TOKEN;
|
||||
use crate::Pool;
|
||||
|
||||
#[get("/api/v2/oauth2/generate_token")]
|
||||
pub async fn generate_token(pool: &State<Pool>, auth: Auth<true>) -> String{
|
||||
let pool = pool.inner();
|
||||
|
||||
|
||||
|
||||
create_token(pool, auth.pid, AUTH_TOKEN, None).await
|
||||
}
|
||||
1
src/json_api/oauth/mod.rs
Normal file
1
src/json_api/oauth/mod.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub mod generate_token;
|
||||
|
|
@ -27,6 +27,7 @@ mod graphql;
|
|||
mod email;
|
||||
mod papi;
|
||||
mod mii_util;
|
||||
mod json_api;
|
||||
|
||||
type Pool = sqlx::Pool<Postgres>;
|
||||
|
||||
|
|
@ -140,6 +141,7 @@ async fn launch() -> _ {
|
|||
nnid::provider::get_nex_token,
|
||||
nnid::provider::get_service_token,
|
||||
nnid::mapped_ids::mapped_ids,
|
||||
json_api::oauth::generate_token::generate_token,
|
||||
papi::login::login,
|
||||
papi::user::get_user,
|
||||
// graphql::graphiql,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue