1
- 'use strict'
1
+ import { Router } from "express" ;
2
+ import * as passport from "passport" ;
3
+ import * as LDAPStrategy from "passport-ldapauth" ;
2
4
3
- const Router = require ( 'express' ) . Router
4
- const passport = require ( 'passport' )
5
- const LDAPStrategy = require ( 'passport-ldapauth' )
6
- const config = require ( '../../config' )
7
- const models = require ( '../../models' )
8
- const logger = require ( '../../logger' )
9
- const { setReturnToFromReferer } = require ( '../utils' )
10
- const { urlencodedParser } = require ( '../../utils' )
11
- const response = require ( '../../response' )
5
+ import * as config from "../../config" ;
6
+ import * as models from "../../models" ;
7
+ import * as logger from "../../logger" ;
8
+ import * as response from "../../response" ;
9
+ import { setReturnToFromReferer } from "../utils" ;
10
+ import { urlencodedParser } from "../../utils" ;
12
11
13
- const ldapAuth = module . exports = Router ( )
12
+ const ldapAuth = Router ( )
13
+ export = ldapAuth
14
14
15
15
passport . use ( new LDAPStrategy ( {
16
16
server : {
@@ -30,9 +30,9 @@ passport.use(new LDAPStrategy({
30
30
31
31
if ( typeof uuid === 'undefined' ) {
32
32
throw new Error ( 'Could not determine UUID for LDAP user. Check that ' +
33
- 'either uidNumber, uid or sAMAccountName is set in your LDAP directory ' +
34
- 'or use another unique attribute and configure it using the ' +
35
- '"useridField" option in ldap settings.' )
33
+ 'either uidNumber, uid or sAMAccountName is set in your LDAP directory ' +
34
+ 'or use another unique attribute and configure it using the ' +
35
+ '"useridField" option in ldap settings.' )
36
36
}
37
37
38
38
var username = uuid
@@ -66,11 +66,15 @@ passport.use(new LDAPStrategy({
66
66
}
67
67
if ( needSave ) {
68
68
user . save ( ) . then ( function ( ) {
69
- if ( config . debug ) { logger . debug ( 'user login: ' + user . id ) }
69
+ if ( config . debug ) {
70
+ logger . debug ( 'user login: ' + user . id )
71
+ }
70
72
return done ( null , user )
71
73
} )
72
74
} else {
73
- if ( config . debug ) { logger . debug ( 'user login: ' + user . id ) }
75
+ if ( config . debug ) {
76
+ logger . debug ( 'user login: ' + user . id )
77
+ }
74
78
return done ( null , user )
75
79
}
76
80
}
0 commit comments