diff --git a/CHANGELOG.md b/CHANGELOG.md index 8991f0e0..94c69534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ ## 1.4.31 (Unreleased) * Fix 'Admin' button in 'My projects' page for administrators +* Set expiration_notif = 0 when manually expiring a user +* Restrict '/user' route results when passing 'short=true' as a get param +* Add list of user DBs back to user page ## 1.4.30 (2024-08-02) diff --git a/manager2/src/app/admin/databases/databases.component.html b/manager2/src/app/admin/databases/databases.component.html index a9903fd5..4b056796 100644 --- a/manager2/src/app/admin/databases/databases.component.html +++ b/manager2/src/app/admin/databases/databases.component.html @@ -154,13 +154,14 @@

Declare existing database (no creation)

-
- +
+ +

- +
diff --git a/manager2/src/app/admin/projects/projects.component.html b/manager2/src/app/admin/projects/projects.component.html index e7d7d3b0..6b1d68dd 100644 --- a/manager2/src/app/admin/projects/projects.component.html +++ b/manager2/src/app/admin/projects/projects.component.html @@ -35,7 +35,7 @@

Project creation

- + diff --git a/manager2/src/app/user/user.component.html b/manager2/src/app/user/user.component.html index 03427a0c..9accec0b 100644 --- a/manager2/src/app/user/user.component.html +++ b/manager2/src/app/user/user.component.html @@ -63,7 +63,7 @@

{{user.uid}}

- +
@@ -341,7 +341,7 @@

Update password

- +

Secondary groups

@@ -395,6 +395,27 @@

Projects

+ +
+
+

Databases

+
+
+
+ + + + + + + + + +
Name
{{db.name}}
+
+
+
+
@@ -511,7 +532,7 @@

{{template.display_name}}

- + diff --git a/manager2/src/app/user/user.component.ts b/manager2/src/app/user/user.component.ts index b870fa0d..1aa07479 100644 --- a/manager2/src/app/user/user.component.ts +++ b/manager2/src/app/user/user.component.ts @@ -3,6 +3,7 @@ import { UserService } from './user.service' import { AuthService } from '../auth/auth.service' import { ConfigService } from '../config.service' import { Website, WebsiteService } from './website.service' +import { Database, DatabaseService} from './database.service' import { PluginService} from '../plugin/plugin.service' import { GroupsService } from '../admin/groups/groups.service' import { ProjectsService } from '../admin/projects/projects.service' @@ -143,6 +144,8 @@ export class UserComponent implements OnInit { website: Website websites: Website[] + databases: Database[] + plugins: any[] plugin_data: any @@ -202,6 +205,7 @@ export class UserComponent implements OnInit { private authService: AuthService, private configService: ConfigService, private websiteService: WebsiteService, + private databaseService: DatabaseService, private pluginService: PluginService, private groupService: GroupsService, private projectService: ProjectsService, @@ -217,6 +221,7 @@ export class UserComponent implements OnInit { this.config = { } this.website = new Website('', '', '', '') this.websites = [] + this.databases = [] this.plugins = [] this.plugin_data = { } this.subscribed = false @@ -404,6 +409,7 @@ export class UserComponent implements OnInit { ); } this.web_list(); + this.db_list(); this.user.secondarygroups.sort(function (a,b) { return a.localeCompare(b); @@ -439,6 +445,13 @@ export class UserComponent implements OnInit { ); } + db_list() { + this.databaseService.listOwner(this.user.uid).subscribe( + resp => this.databases = resp, + err => console.log('failed to get databases') + ) + } + web_list() { this.websiteService.listOwner(this.user.uid).subscribe( resp => this.websites = resp, diff --git a/manager2/src/app/user/user.service.ts b/manager2/src/app/user/user.service.ts index 0993567b..63337368 100644 --- a/manager2/src/app/user/user.service.ts +++ b/manager2/src/app/user/user.service.ts @@ -303,7 +303,7 @@ export class UserService { //}), }; return this.http.get( - environment.apiUrl + '/user', + environment.apiUrl + '/user?short=true', httpOptions).pipe(map((response: any[]) => { return response.sort(function (a,b) { return a.uid.localeCompare(b.uid); diff --git a/routes/database.js b/routes/database.js index e5157917..00b7cb7c 100644 --- a/routes/database.js +++ b/routes/database.js @@ -45,7 +45,7 @@ router.put('/database/:id/owner/:old/:new', async function(req, res) { res.status(401).send({ message: 'Not authorized' }); return; } - + await dbsrv.mongo_databases().updateOne({name: req.params.id}, {'$set': {owner: req.params.new}}); await dbsrv.mongo_events().insertOne({ 'owner': session_user.uid, @@ -282,10 +282,7 @@ router.post('/database/declare/:id', async function(req, res) { res.status(401).send({ message: 'Only admins can declare a database' }); return; } - if (!req.body.expire) { - res.status(403).send({ message: 'No expiration date' }); - return; - } + let db = { owner: req.body.owner ? req.body.owner : session_user.uid, name: req.params.id, @@ -293,7 +290,6 @@ router.post('/database/declare/:id', async function(req, res) { host: req.body.host && sansrv.sanitize(req.body.host) ? req.body.host : CONFIG.mysql.host, usage: req.body.usage ? req.body.usage : '', size: req.body.size ? req.body.size : '', - expire: req.body.expire, single_user: req.body.single_user !== undefined ? req.body.single_user : true }; try { diff --git a/routes/users.js b/routes/users.js index af3d313a..73b23107 100644 --- a/routes/users.js +++ b/routes/users.js @@ -367,7 +367,16 @@ router.get('/user', async function(req, res) { res.status(401).send({ message: 'Not authorized' }); return; } - let users = await dbsrv.mongo_users().find({ }).toArray(); + + let users; + + if (req.query.short === 'true') { + users = await dbsrv.mongo_users().find({ }).project({ + history: 0, + }).toArray(); + } else { + users = await dbsrv.mongo_users().find({ }).toArray(); + } res.json(users); }); @@ -927,7 +936,7 @@ router.get('/user/:id/expire', async function(req, res) { } user.history.push({ 'action': 'expire', date: new Date().getTime() }); // eslint-disable-next-line no-unused-vars - await dbsrv.mongo_users().updateOne({ uid: user.uid },{ '$set': { status: STATUS_EXPIRED, expiration: new Date().getTime(), history: user.history } }); + await dbsrv.mongo_users().updateOne({ uid: user.uid },{ '$set': { status: STATUS_EXPIRED, expiration: new Date().getTime(), history: user.history, expiration_notif: 0 } }); try { let created_file = await filer.user_expire_user(user, fid);