Skip to content

Commit

Permalink
feat: loginURLFormatter support context (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
hustxiaoc authored and dead-horse committed Oct 28, 2016
1 parent 28bbb27 commit 64b0466
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ we will use [path-match](https://github.com/expressjs/path-match) transfer it to
* `''` empty string meaning match all, @see `path-match` package.
* - {String|Regex|Function(pathname, ctx)} ignore, detect which url no need to check user auth.
* If `match` exists, this argument will be ignored.
* - {Function(url, rootPath)} loginURLFormatter, format the login url.
* - {Function(url, rootPath, ctx)} loginURLFormatter, format the login url.
* - {String} [rootPath], custom app url root path, default is '/'.
* - {String} [loginPath], default is '/login'.
* - {String} [loginCallbackPath], default is `options.loginPath + '/callback'`.
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var defaultOptions = {
*
* @param {String|Regex|Function(pathname, ctx)} match, detect which url need to check user auth.
* @param {Object} options
* - {Function(url, rootPath)} loginURLFormatter, format the login url.
* - {Function(url, rootPath, ctx)} loginURLFormatter, format the login url.
* - {String} [rootPath], custom app url root path, default is '/'.
* - {String} [loginPath], default is '/login'.
* - {String} [loginCallbackPath], default is `options.loginPath + '/callback'`.
Expand Down Expand Up @@ -299,7 +299,7 @@ function login(options) {
var host = defaultHost || this.host;
var protocol = options.protocol || this.protocol;
var currentURL = protocol + '://' + host + loginCallbackPath;
var loginURL = options.loginURLFormatter(currentURL, options.rootPath);
var loginURL = options.loginURLFormatter(currentURL, options.rootPath, this);
debug('login redrect to loginURL: %s', loginURL);
redirect(this, loginURL);
};
Expand Down

0 comments on commit 64b0466

Please sign in to comment.