mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
Implement logout endpoint
This commit is contained in:
parent
3d9af3152e
commit
25e00a3172
4 changed files with 27 additions and 1 deletions
|
@ -24,6 +24,7 @@ module.exports = function(config, auth, storage) {
|
||||||
app.param('tag', validate_name)
|
app.param('tag', validate_name)
|
||||||
app.param('version', validate_name)
|
app.param('version', validate_name)
|
||||||
app.param('revision', validate_name)
|
app.param('revision', validate_name)
|
||||||
|
app.param('token', validate_name)
|
||||||
|
|
||||||
// these can't be safely put into express url for some reason
|
// these can't be safely put into express url for some reason
|
||||||
app.param('_rev', match(/^-rev$/))
|
app.param('_rev', match(/^-rev$/))
|
||||||
|
@ -204,6 +205,13 @@ module.exports = function(config, auth, storage) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.delete('/-/user/token/:token', function(req, res, next) {
|
||||||
|
res.status(200)
|
||||||
|
next({
|
||||||
|
ok: 'Logged out',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
function tag_package_version(req, res, next) {
|
function tag_package_version(req, res, next) {
|
||||||
if (typeof(req.body) !== 'string') return next('route')
|
if (typeof(req.body) !== 'string') return next('route')
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ describe('Func', function() {
|
||||||
require('./scoped')()
|
require('./scoped')()
|
||||||
require('./security')()
|
require('./security')()
|
||||||
require('./adduser')()
|
require('./adduser')()
|
||||||
|
require('./logout')()
|
||||||
require('./addtag')()
|
require('./addtag')()
|
||||||
require('./plugins')()
|
require('./plugins')()
|
||||||
|
|
||||||
|
@ -85,4 +86,3 @@ process.on('unhandledRejection', function (err) {
|
||||||
throw err
|
throw err
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,13 @@ Server.prototype.auth = function(user, pass) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Server.prototype.logout = function(token) {
|
||||||
|
return this.request({
|
||||||
|
uri: '/-/user/token/'+encodeURIComponent(token),
|
||||||
|
method: 'DELETE'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
Server.prototype.get_package = function(name) {
|
Server.prototype.get_package = function(name) {
|
||||||
return this.request({
|
return this.request({
|
||||||
uri: '/'+encodeURIComponent(name),
|
uri: '/'+encodeURIComponent(name),
|
||||||
|
|
11
test/functional/logout.js
Normal file
11
test/functional/logout.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
module.exports = function() {
|
||||||
|
var server = process.server
|
||||||
|
|
||||||
|
describe('logout', function() {
|
||||||
|
it('should log out', function () {
|
||||||
|
return server.logout('some-token')
|
||||||
|
.status(200)
|
||||||
|
.body_ok(/Logged out/)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue