GithubHelp home page GithubHelp logo

Comments (3)

tvallotton avatar tvallotton commented on May 16, 2024

Thanks for bringing this to my attention. This is definitely not intended. I don't think that modifying the Display impl of Error will be sufficient to fix this. Since the validator::ValidationErrors is still accessible from the error and it holds the password.
I don't know what the best aproach to fix this may be, but I will attempt this problem on the weekend.

from rocket_auth.

ywegel avatar ywegel commented on May 16, 2024

I created an issue in the 'validator' repository, but no one answered. Using the ValidatorError directly (not via the derive) it is not possible to set the error message. You can only set the code via the ValidatorError::new(...).
I fixed "this" in my project by dirty matching the error type:
`
#[derive(Error, Debug)]
pub enum ResponseError {
...
//all error types
#[error("{0}")]
RocketAuthError(#[from] rocket_auth::Error),
...
}

impl ResponseError {
pub fn message(&self) -> String {
match self {
ResponseError::RocketAuthError(e) => {
match e {
Error::FormValidationError(validation_error) => {
format!("{}", validation_error.code)
}
Error::FormValidationErrors(validation_errors) => {
let mut buffer = String::new();
let f = validation_errors
.field_errors()
.values()
.map(|x| {
x.iter().map(|y| {
y.code.to_string()
}).collect::()
}).collect();
f
}
... //match rest
}
}
}
`
This is completly stupid, but it does the job. Maybe it can help you

from rocket_auth.

tvallotton avatar tvallotton commented on May 16, 2024

I think we'd have to consider to remove the dependency on validator and refactor Error, though that would be a masive breaking change.

from rocket_auth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.