mirror of
https://github.com/mohamadihsan/topuponline.git
synced 2026-12-06 11:36:28 +00:00
Refactor backend services and preserve transaction contracts
This commit is contained in:
@@ -4,61 +4,11 @@ const bcrypt = require('bcrypt');
|
||||
const helper = require('../../helpers/helper');
|
||||
const winston = require('../../helpers/winston.logger');
|
||||
const model = require('./auth.model');
|
||||
const { body, validationResult } = require('express-validator');
|
||||
const { validationResult } = require('express-validator');
|
||||
const validate = require('./auth.validation');
|
||||
const moment = require('moment');
|
||||
moment.locale('id');
|
||||
|
||||
// VALIDATION
|
||||
const validate = (method) => {
|
||||
switch (method) {
|
||||
case 'loginPartnerUser': {
|
||||
return [
|
||||
body('email')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Email is required')
|
||||
.isEmail()
|
||||
.withMessage('Email format wrong'),
|
||||
body('password').not().isEmpty().withMessage('Password is required'),
|
||||
];
|
||||
}
|
||||
case 'loginTerminal': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('password').not().isEmpty().withMessage('Password is required'),
|
||||
];
|
||||
}
|
||||
case 'register': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
body('password')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Password is required')
|
||||
.isLength({ min: 5 })
|
||||
.withMessage('Password must be least 5 characters'),
|
||||
];
|
||||
}
|
||||
case 'refreshTokenPartnerUser': {
|
||||
return [
|
||||
body('email')
|
||||
.not()
|
||||
.isEmpty()
|
||||
.withMessage('Email is required')
|
||||
.isEmail()
|
||||
.withMessage('Email format wrong'),
|
||||
];
|
||||
}
|
||||
case 'refreshTokenTerminal': {
|
||||
return [
|
||||
body('mid').not().isEmpty().withMessage('MID is required'),
|
||||
body('tid').not().isEmpty().withMessage('TID is required'),
|
||||
];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ================================================================= LOGIN BY PARTNER USER =================================================================
|
||||
// *Created By: Mohamad Ihsan*
|
||||
|
||||
Reference in New Issue
Block a user