marek 1 месяц назад
Родитель
Сommit
4d5c52f9e4
3 измененных файлов с 16 добавлено и 0 удалено
  1. 6 0
      routes/include/panel.js
  2. 2 0
      utils/auth.js
  3. 8 0
      utils/meteostanice.js

+ 6 - 0
routes/include/panel.js

@@ -89,6 +89,12 @@ export default (langName, lang) => new Elysia({ prefix: "/panel" })
 
     Auth.editUser(session.email, newName, newEmail)
 
+    Auth.removeSession(session.id)
+
+    const newSession = await Auth.createSession(newEmail)
+    
+    cookie.session.value = newSession.token
+
     set.headers['content-type'] = 'text/html; charset=utf8'
     return redirect(`/${langName === "sk" ? `` : `${langName}/`}panel`)
   })

+ 2 - 0
utils/auth.js

@@ -135,6 +135,8 @@ export default class Auth {
             where email = ?;
         `).run(newName, newEmail, email)
 
+        Meteostanice.editOwnerOnOwned(email, newEmail)
+
         return result
     }
 

+ 8 - 0
utils/meteostanice.js

@@ -115,6 +115,14 @@ export default class Meteostanice {
         `).run(newName, newDescription, newOwner, id)
     }
 
+    static editOwnerOnOwned(owner, newOwner) {
+        meteostaniceDB.prepare(`
+            update list
+            owner = ?
+            where owner = ?;
+        `).run(newOwner, owner)
+    }
+
     static remove(id) {
         meteostaniceDB.prepare(`
             DELETE