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
/dist
/dist-lib
/dist-server
/tmp
/out-tsc
......
# Contributing to angular-aap-auth
Thanks for your willingness to contribute and help to the angular-aap-auth
library.
## Setup
If you have writing permission into project's repo, then clone it locally.
```
git clone https://gitlab.ebi.ac.uk/tools-glue/angular-aap-auth
or
git clone git@gitlab.ebi.ac.uk:tools-glue/angular-aap-auth
```
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.
```
yarn
or
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
[Karma](https://karma-runner.github.io).
#!/bin/sh
#
# 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
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# 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
then
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
EOF
exit 1
fi
printf "Running lint... "
RED='\033[1;31m'
GREEN='\033[0;32m'
NC='\033[0m'
lint=$(yarn lint 2>&1)
ret_code=$?
# 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
else
printf "${GREEN}passed.${NC}\n"
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
#!/bin/sh
content=`cat "$1"`
cat <<-EOF > "$1"
#[feat|fix|docs|style|refactor|perf|test|chore]:-|
#[what/why]
$content
EOF
......@@ -23,7 +23,7 @@ import {
} from './token.service';
export interface LoginOptions {
[key: string]: string
[key: string]: string;
}
@Injectable()
......@@ -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