Last active
August 29, 2015 14:04
-
-
Save mctep/84004262aa25f6219347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.use( | |
// меняет токен на user | |
// создает в req объект user: | |
// req.user = { id: 1, roles: [...] } | |
exchangePassportToken | |
) | |
app | |
.put('/users/:uid') | |
.use(roles('manager')) | |
.use(allowBody( | |
['password', function(pass) { | |
return pass.length > 12; | |
}], | |
'contacts.*', | |
)) | |
.use(updateUser) | |
.use(allowResponseBody( | |
'id', | |
'contacts', | |
'login', | |
'laslogin' | |
)) | |
.use(sendResponse); | |
app | |
.put('/users/:uid') | |
.use(roles('client')) | |
.use(allowRequest( | |
['params.uid', eq('req.user.id')], | |
['body.password', [ | |
is(String), | |
length.gt(12), | |
containsOnly('0123456789ABCDEF...'), | |
regMatch(/[01234...]+/) | |
]], | |
'body.contacts.phone' | |
)) | |
.use(updateUser) | |
.use(allowResponseBody( | |
'id', | |
'contacts', | |
'login' | |
)) | |
.use(sendResponse); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment