Commit 93df732d authored by Eduardo Sanz García's avatar Eduardo Sanz García
Browse files

feat: added githooks

parent 3aee6416
......@@ -2,6 +2,7 @@
# compiled output
# Contributing to angular-aap-auth
Thanks for your willingness to contribute and help to the angular-aap-auth
## Setup
If you have writing permission into project's repo, then clone it locally.
git clone
git clone
Otherwise, fork the repo using GitLab, and submit pull requests.
All the commits should pass the `ng lint` command. Therefore, we recommend that
you set a `pre-commit` git hook in this way:
ln -s ../../githooks/pre-commit .git/hooks/pre-commit
Then download the dependencies.
npm -i
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app
will automatically reload if you change any of the source files. It is
recommended to use the git hooks provided:
## Build library
Run `yarn packagr` or `npm packagr` to build the library. The build artifacts
will be stored in the `dist-lib/` directory.
## Running unit tests
Run `ng test` to execute the unit tests via
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
# Initial commit: diff against an empty tree object
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
exit 1
printf "Running lint... "
lint=$(yarn lint 2>&1)
# If it didn't pass, announce it failed and print the output
if [ $ret_code != 0 ]; then
printf "${RED}failed:${NC}\n"
printf "${lint}\n"
exit 1
printf "${GREEN}passed.${NC}\n"
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
content=`cat "$1"`
cat <<-EOF > "$1"
......@@ -23,7 +23,7 @@ import {
} from './token.service';
export interface LoginOptions {
[key: string]: string
[key: string]: string;
......@@ -194,7 +194,7 @@ export class AuthService {
const hardLimit = 60 * 24;
if (ttl > hardLimit) {
window.console.error(`Login requested with an expiration longer than ${hardLimit} minutes! This is not allowed.`);
window.console.error(`Expiration request reset to ${hardLimit} minutes.`)
window.console.error(`Expiration request reset to ${hardLimit} minutes.`);
options['ttl'] = '' + hardLimit;
} else if (ttl > softLimit) {
window.console.warn(`Login requested with an expiration longer than ${softLimit} minutes!`);
......@@ -31,7 +31,7 @@ export class TokenService {
try {
return !this._jwt.isTokenExpired();
} catch (error) {
return false
return false;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment