DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

af3190bed9e9dd03b5a6721255e426a5b417b2d9 — Jonni Liljamo 1 year, 9 months ago 9e99a5d
feat(api): create session on register
1 files changed, 6 insertions(+), 1 deletions(-)

M api/src/handlers/user/create.rs
M api/src/handlers/user/create.rs => api/src/handlers/user/create.rs +6 -1
@@ 6,6 6,7 @@
 * See LICENSE for licensing information.
 */

use actix_session::Session;
use actix_web::{post, web, HttpResponse, Responder};
use email_address::EmailAddress;



@@ 16,6 17,7 @@ use crate::{actions, models, PgPool};
#[post("/api/user")]
pub(crate) async fn create(
    pool: web::Data<PgPool>,
    session: Session,
    user: web::Json<models::InsertableUser>,
) -> impl Responder {
    if user.username.len() < 3 {


@@ 48,7 50,10 @@ pub(crate) async fn create(
            Err(err) => {
                return HttpResponse::InternalServerError().json(err);
            }
            Ok(user) => HttpResponse::Ok().json(user),
            Ok(user) => match session.insert("user_id", user.id) {
                Err(err) => HttpResponse::InternalServerError().body(err.to_string()),
                Ok(_) => HttpResponse::Ok().json(user),
            },
        },
    }
}