//! Small example application for Portier using the Rocket framework. use log::error; use rocket::{ form::Form, get, http::{uri::Absolute, Status}, launch, post, response::{content::RawHtml, Redirect}, routes, FromForm, State, }; /// Struct used to deserialize form data for `POST /auth`. #[derive(FromForm)] struct AuthForm { email: String, } /// Struct used to deserialize form data for `POST /verify`. #[derive(FromForm)] struct VerifyForm { id_token: String, } /// Render a simple index page with a login form. #[get("/")] fn index() -> RawHtml<&'static str> { RawHtml( r#"
Enter your email address:
"#, ) } /// Handle the login form `POST /auth` request. /// /// This creates a login session using `portier::Client::start_auth`, and redirects the browser to /// complete the login. #[post("/auth", data = "