-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18775e7
commit c1ad4ae
Showing
7 changed files
with
145 additions
and
87 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* eslint-disable no-console */ | ||
const lofcg = require('../'); | ||
|
||
const username = '<username>'; | ||
const password = '<password>'; | ||
|
||
// Check no valid session | ||
lofcg.session.validate((errValidate, isValidInitially) => { | ||
if (errValidate) { | ||
console.log('An error has occurred validating session:', errValidate); | ||
return; | ||
} | ||
|
||
console.log('Is session valid?', isValidInitially); | ||
|
||
// Log in | ||
lofcg.session.create(username, password, (errCreate, userId) => { | ||
if (errCreate) { | ||
console.log('An error has occurred logging in:', errCreate); | ||
return; | ||
} | ||
|
||
console.log('Logged in as:', userId); | ||
|
||
// Check session is now valid | ||
lofcg.session.validate((errValidate2, isValidAfterLogin) => { | ||
if (errValidate2) { | ||
console.log('An error has occurred validating session:', errValidate2); | ||
return; | ||
} | ||
|
||
console.log('Is session valid?', isValidAfterLogin); | ||
|
||
// Get session value | ||
lofcg.session.get((errGet, session) => { | ||
if (errGet) { | ||
console.log('An error has occurred getting session:', errGet); | ||
return; | ||
} | ||
|
||
console.log('Got session for:', session.username); | ||
|
||
// Log out | ||
lofcg.session.destroy((errDestroy) => { | ||
if (errDestroy) { | ||
console.log('An error has occurred logging out:', errDestroy); | ||
return; | ||
} | ||
|
||
console.log('Logged out'); | ||
|
||
// Check session has invalidated | ||
lofcg.session.validate((errValidate3, isValidAfterLogout) => { | ||
if (errValidate3) { | ||
console.log('An error has occurred validating session:', errValidate3); | ||
return; | ||
} | ||
|
||
console.log('Is session valid?', isValidAfterLogout); | ||
|
||
// Get session value | ||
lofcg.session.set(session, (errSet, success) => { | ||
if (errSet) { | ||
console.log('An error has occurred setting session:', errSet); | ||
return; | ||
} | ||
|
||
console.log('Set session', success); | ||
|
||
// Check session has loaded | ||
lofcg.session.validate((errValidate4, isValidAfterLoading) => { | ||
if (errValidate4) { | ||
console.log('An error has occurred validating session:', errValidate4); | ||
return; | ||
} | ||
|
||
console.log('Is session valid?', isValidAfterLoading); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |