(
&self,
request: Request<api::LoginRequest>,
)
| 142 | #[tonic::async_trait] |
| 143 | impl InternalService for Internal { |
| 144 | async fn login( |
| 145 | &self, |
| 146 | request: Request<api::LoginRequest>, |
| 147 | ) -> Result<Response<api::LoginResponse>, Status> { |
| 148 | let req = request.get_ref(); |
| 149 | let u = user::get_by_email_and_pw(&req.email, &req.password) |
| 150 | .await |
| 151 | .map_err(|e| e.status())?; |
| 152 | |
| 153 | let token = claims::AuthClaim::new_for_user(&u.id) |
| 154 | .encode(self.jwt_secret.as_ref()) |
| 155 | .map_err(|e| e.status())?; |
| 156 | |
| 157 | Ok(Response::new(api::LoginResponse { jwt: token })) |
| 158 | } |
| 159 | |
| 160 | async fn profile( |
| 161 | &self, |
no test coverage detected