screwdriver-api 4.1.288 → 4.1.290

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screwdriver-api",
3
- "version": "4.1.288",
3
+ "version": "4.1.290",
4
4
  "description": "API server for the Screwdriver.cd service",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,6 +35,10 @@ server.register({
35
35
 
36
36
  `PUT /users/{id}/settings`
37
37
 
38
+ #### Delete all user's settings
39
+
40
+ `DELETE /users/{id}/settings`
41
+
38
42
  **Arguments**
39
43
 
40
44
  * `settings` - An optional new object with user settings.
@@ -2,6 +2,7 @@
2
2
 
3
3
  const getSettingsRoute = require('./settings/get');
4
4
  const updateSettingsRoute = require('./settings/update');
5
+ const removeSettingsRoute = require('./settings/delete');
5
6
 
6
7
  /**
7
8
  * Users API Plugin
@@ -11,7 +12,7 @@ const updateSettingsRoute = require('./settings/update');
11
12
  const usersPlugin = {
12
13
  name: 'users',
13
14
  async register(server) {
14
- server.route([getSettingsRoute(), updateSettingsRoute()]);
15
+ server.route([getSettingsRoute(), updateSettingsRoute(), removeSettingsRoute()]);
15
16
  }
16
17
  };
17
18
 
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ const boom = require('@hapi/boom');
4
+
5
+ module.exports = () => ({
6
+ method: 'DELETE',
7
+ path: '/users/settings',
8
+ options: {
9
+ description: 'Reset user settings',
10
+ notes: 'Reset user settings',
11
+ tags: ['api', 'users'],
12
+ auth: {
13
+ strategies: ['token'],
14
+ scope: ['user', '!guest']
15
+ },
16
+
17
+ handler: async (request, h) => {
18
+ const { userFactory } = request.server.app;
19
+ const { scmContext, username } = request.auth.credentials;
20
+ const user = await userFactory.get({ username, scmContext });
21
+
22
+ if (!user) {
23
+ throw boom.notFound('User does not exist');
24
+ }
25
+
26
+ return user.removeSettings().then(results => {
27
+ return h.response(results).code(200);
28
+ });
29
+ }
30
+ }
31
+ });