mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-07-21 09:38:31 +02:00
Merge pull request #164 from kerolloz/master
Add customDecoded optional function
This commit is contained in:
commit
d714939e0d
@ -79,7 +79,9 @@ function noQsMethod (options) {
|
|||||||
|
|
||||||
// success handler
|
// success handler
|
||||||
const onSuccess = () => {
|
const onSuccess = () => {
|
||||||
socket[options.decodedPropertyName] = decoded;
|
socket[options.decodedPropertyName] = options.customDecoded
|
||||||
|
? options.customDecoded(decoded)
|
||||||
|
: decoded;
|
||||||
socket.emit('authenticated');
|
socket.emit('authenticated');
|
||||||
if (server.$emit) {
|
if (server.$emit) {
|
||||||
server.$emit('authenticated', socket);
|
server.$emit('authenticated', socket);
|
||||||
@ -203,7 +205,9 @@ function authorize (options) {
|
|||||||
return auth.fail(error, socket, accept);
|
return auth.fail(error, socket, accept);
|
||||||
}
|
}
|
||||||
|
|
||||||
socket[options.decodedPropertyName] = decoded;
|
socket[options.decodedPropertyName] = options.customDecoded
|
||||||
|
? options.customDecoded(decoded)
|
||||||
|
: decoded;
|
||||||
|
|
||||||
return auth.success(socket, accept);
|
return auth.success(socket, accept);
|
||||||
};
|
};
|
||||||
|
1
types/index.d.ts
vendored
1
types/index.d.ts
vendored
@ -28,6 +28,7 @@ declare module 'socketio-jwt' {
|
|||||||
|
|
||||||
interface IOptions {
|
interface IOptions {
|
||||||
additional_auth?: (decoded: object, onSuccess: () => void, onError: (err: (string | ISocketIOError), code: string) => void) => void;
|
additional_auth?: (decoded: object, onSuccess: () => void, onError: (err: (string | ISocketIOError), code: string) => void) => void;
|
||||||
|
customDecoded?: (decoded: object) => object;
|
||||||
|
|
||||||
callback?: (false | number);
|
callback?: (false | number);
|
||||||
secret: (string | ((request: any, decodedToken: object, callback: ISocketCallback) => void));
|
secret: (string | ((request: any, decodedToken: object, callback: ISocketCallback) => void));
|
||||||
|
Loading…
Reference in New Issue
Block a user