tvallotton / rocket_auth

An implementation for an authentication API for Rocket applications.
https://docs.rs/rocket_auth/
Apache License 2.0
73 stars 35 forks source link

Trait FromRequest not implemented for User/Admin when trying to use guards #34

Closed SpootDev closed 2 years ago

SpootDev commented 2 years ago

rust 1.60 stable rocket_auth = { version = "0.4.0", features = ["sqlx-postgres"] } rocket = { git = "https://github.com/SergioBenitez/Rocket/", features = ["json", "secrets", "uuid"]} rocket_dyn_templates = { git = "https://github.com/SergioBenitez/Rocket/", features = ["tera"]}

I see the traits in the rocket_auth lib.......so, obviously, I'm doing something silly. Looking for input on what I'm doing wrong.

use rocket_auth::{Users, Error, Auth, Signup, Login, User, AdminUser};

[get("/admin-panel")]

fn admin_panel(user: AdminUser) -> String { format!("Hello {}.", user.email()) }

error[E0277]: the trait bound rocket_auth::AdminUser: FromRequest<'_> is not satisfied --> src/admin/bp_user.rs:27:22 | 27 | fn adminpanel(user: AdminUser) -> String { | ^^^^^^^^^ the trait `FromRequest<'>is not implemented forrocket_auth::AdminUser`

SpootDev commented 2 years ago

Specifying the rc1 cleared this up. rocket = { version = "0.5.0-rc.1", features = ["json", "secrets", "uuid"]} rocket_dyn_templates = { version = "0.1.0-rc.1", features = ["tera"]}