fn write(&mut self, resp: HttpResponse) -> Result<MiddlewareResponse, ActixWebError> {
        match self.state {
            SqlIdentityState::Created => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.create(self, resp)))
            },

            SqlIdentityState::Updated if self.token.is_some() && self.identity.is_some() => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.save(self, resp)))
            }

            SqlIdentityState::Deleted if self.token.is_some() => {
                let token = self.token.as_ref().expect("[SIS::Deleted] Token is None!");
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.remove(token, resp)))
            }

            SqlIdentityState::Deleted | SqlIdentityState::Updated => {
                // Not logged in/log in failed
                Err(error::ErrorBadRequest(SqlIdentityError::TokenRequired))
            }

            _ => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Done(resp))
            }
        }
    }
/// Saves the identity to the backing store, if it has changed
///
/// # Arguments
///
/// * `resp` - HTTP response to modify
Saves the identity to the backing store, if it has changed
Saves the identity to the backing store if it has changed
fn write(&mut self, resp: HttpResponse) -> Result<MiddlewareResponse, ActixWebError> {
        match self.state {
            SqlIdentityState::Created => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.create(self, resp)))
            },
            SqlIdentityState::Updated if self.token.is_some() && self.identity.is_some() => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.save(self, resp)))
            }
            SqlIdentityState::Deleted if self.token.is_some() => {
                let token = self.token.as_ref().expect("[SIS::Deleted] Token is None!");
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Future(self.inner.remove(token, resp)))
            }
            SqlIdentityState::Deleted | SqlIdentityState::Updated => {
                // Not logged in/log in failed
                Err(error::ErrorBadRequest(SqlIdentityError::TokenRequired))
            }
            _ => {
                self.state = SqlIdentityState::Unchanged;
                Ok(MiddlewareResponse::Done(resp))
            }
        }
    }
fn write ( & mut self , resp : HttpResponse ) -> Result < MiddlewareResponse , ActixWebError > { match self . state { SqlIdentityState :: Created => { self . state = SqlIdentityState :: Unchanged ; Ok ( MiddlewareResponse :: Future ( self . inner . create ( self , resp ) ) ) } , SqlIdentityState :: Updated if self . token . is_some ( ) && self . identity . is_some ( ) => { self . state = SqlIdentityState :: Unchanged ; Ok ( MiddlewareResponse :: Future ( self . inner . save ( self , resp ) ) ) } SqlIdentityState :: Deleted if self . token . is_some ( ) => { let token = self . token . as_ref ( ) . expect ( " " ) ; self . state = SqlIdentityState :: Unchanged ; Ok ( MiddlewareResponse :: Future ( self . inner . remove ( token , resp ) ) ) } SqlIdentityState :: Deleted | SqlIdentityState :: Updated => { // Not logged in/log in failed Err ( error :: ErrorBadRequest ( SqlIdentityError :: TokenRequired ) ) } _ => { self . state = SqlIdentityState :: Unchanged ; Ok ( MiddlewareResponse :: Done ( resp ) ) } } }
Saves the identity to the backing store, if it has changed
Saves the identity to the backing store if it has changed
&mut self
resp
HttpResponse
&mut self
resp
HttpResponse