-
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.
Merge pull request #34 from andela/ft-user-login-164395525
#164395525: user should be able to login
- Loading branch information
Showing
8 changed files
with
323 additions
and
3 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 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 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,40 @@ | ||
/** | ||
* @class Trimmer | ||
* @description Trims data | ||
* @exports AuthenticateUser | ||
*/ | ||
class Trimmer { | ||
/** | ||
* @method trimValues | ||
* @description Takes in an object and returns it with all the values trimmed | ||
* @param {object} data - The object to be trimmed | ||
* @returns {object} - trimmed data | ||
*/ | ||
static trimValues(data) { | ||
const dataKeys = Object.keys(data); | ||
const trimmedData = {}; | ||
for (let i = 0; i < dataKeys.length; i += 1) { | ||
const key = dataKeys[i]; | ||
const value = data[key]; | ||
trimmedData[key] = (key !== 'password' && typeof value === 'string') ? value.trim() : value; | ||
} | ||
return trimmedData; | ||
} | ||
|
||
/** | ||
* @method trimBody | ||
* @description Trims the request body | ||
* @param {object} req - The Request Object | ||
* @param {object} res - The Response Object | ||
* @param {callback} next - Callback method | ||
* @returns {undefined} - | ||
*/ | ||
static trimBody(req, res, next) { | ||
if (req.body) { | ||
req.body = Trimmer.trimValues(req.body); | ||
} | ||
return next(); | ||
} | ||
} | ||
|
||
export default Trimmer; |
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.
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 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 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