yazid138 2 年之前
父节点
当前提交
053c69fc09
共有 4 个文件被更改,包括 33 次插入28 次删除
  1. 3 3
      .gitignore
  2. 1 1
      Jenkinsfile
  3. 28 23
      controller/auth.controller.js
  4. 1 1
      controller/pelanggaran.controller.js

+ 3 - 3
.gitignore

@@ -55,7 +55,7 @@ typings/
 .yarn-integrity
 
 # dotenv environment variables file
-.env
+#.env
 
 # next.js build output
 # .next
@@ -65,6 +65,6 @@ typings/
 
 public/images/
 
-Jenkinsfile
+#Jenkinsfile
 
-dockerfile
+#dockerfile

+ 1 - 1
Jenkinsfile

@@ -12,8 +12,8 @@ node {
     // environment {
       registryAddress = "https://registry.sidali.kemdikbud.go.id"
       registryCredential = 'DockerRegistry-ID'
+
     // }
-	
     stage('Checkout') {
       checkout scm
     }

+ 28 - 23
controller/auth.controller.js

@@ -41,12 +41,12 @@ exports.login = handleError(async (req, res) => {
     user_id: user.id,
   })
   let role = null
-  if (process.env.ENV === 'production') {
-    role = user.peran.filter((e) => roleDataProduction.includes(e.peran.id))[0]
-    role.peran.id = convertRole(role.peran.id)
-  } else {
-    role = user.peran.filter((e) => roleDataProduction.includes(e.peran.id))[0]
-  }
+  //if (process.env.ENV === 'production') {
+  role = user.peran.filter((e) => roleDataProduction.includes(e.peran.id))[0]
+  role.peran.id = convertRole(role.peran.id)
+  /*} else {
+    role = user.peran.filter((e) => roleData.includes(e.peran.id))[0]
+  }*/
   let dataRole = {
     id: role.peran.id,
     nama: role.peran.nama,
@@ -65,22 +65,22 @@ exports.login = handleError(async (req, res) => {
       isPrivate: false,
     })
   } else {
-    if (process.env.ENV === 'production') {
-      if (cekUser.role.id !== role.peran.id) {
-        await userModel.updateOne({ _id: cekUser._id }, { role: dataRole })
-      }
-      if (!cekUser.lembaga) {
-        await userModel.updateOne(
-          { _id: cekUser._id },
-          { lembaga: role.organisasi }
-        )
-      }
-      if (cekUser.role.id !== role.peran.id || !cekUser.lembaga) {
-        cekUser = await userModel.findOne({
-          user_id: user.id,
-        })
-      }
+    //if (process.env.ENV === 'production') {
+    if (cekUser.role.id !== role.peran.id) {
+      await userModel.updateOne({ _id: cekUser._id }, { role: dataRole })
+    }
+    if (!cekUser.lembaga) {
+      await userModel.updateOne(
+        { _id: cekUser._id },
+        { lembaga: role.organisasi }
+      )
     }
+    if (cekUser.role.id !== role.peran.id || !cekUser.lembaga) {
+      cekUser = await userModel.findOne({
+        user_id: user.id,
+      })
+    }
+    //}
   }
 
   const accessToken = jwt.sign({ _id: cekUser._id }, process.env.SECRET, {
@@ -93,7 +93,10 @@ exports.login = handleError(async (req, res) => {
   const now = new Date()
   const time = now.getTime()
   now.setTime(time + 24 * 60 * 60 * 1000)
-  res.cookie('sidali-cookie', accessToken, { httpOnly: true, expires: now })
+  res.cookie('sidali-cookie', accessToken, {
+    httpOnly: true,
+    expires: now,
+  })
 
   response.success(res, {
     message: 'Berhasil Login',
@@ -102,7 +105,9 @@ exports.login = handleError(async (req, res) => {
 })
 
 exports.logout = (req, res) => {
-  res.cookie('sidali-cookie', '', { expires: new Date() })
+  res.cookie('sidali-cookie', '', {
+    expires: new Date(),
+  })
 
   response.success(res, {
     message: 'Berhasil Logout',

+ 1 - 1
controller/pelanggaran.controller.js

@@ -35,7 +35,7 @@ exports.sanksi = handleError(async (req, res) => {
   if (user.role.id === 2021) {
     w.level_sanksi = 1
   } else {
-    w.level_sanksi = 3
+    w.level_sanksi = { $in: [3, 2] }
     if (down === 'true') {
       w.level_sanksi = { $in: [1, 2] }
     }