cityssm/faster-web-helper

View on GitHub
modules/purchaseOrderApprovals/handlers/post/doValidateUserKeyGuid.js

Summary

Maintainability
A
0 mins
Test Coverage
import { getUserByUserKeyGuid } from '../../database/getUser.js';
export default function handler(request, response) {
    const userKeyGuid = (request.body.userKeyGuid ?? '');
    const user = getUserByUserKeyGuid(userKeyGuid);
    if (user === undefined) {
        response.json({
            isLoggedIn: false
        });
    }
    else {
        request.session.purchaseOrderApprovalUser = {
            userName: user.userName,
            approvalMax: user.approvalMax,
            userKeyGuid: user.userKeyGuid,
            isAdmin: user.isAdmin
        };
        response.json({
            isLoggedIn: true,
            userName: user.userName,
            userKeyGuid: user.userKeyGuid
        });
    }
}