mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Allow doLogin
to be called with a set of parameters
This can be used for themes/plugins to specify additional URL parameters to be used when starting authentication. Example usage: ``` LoginMethod.findAll()[0].doLogin({params: {mydata: "myvalue"}}); ```
This commit is contained in:
parent
502f154cfc
commit
4d5b142f1d
@ -21,7 +21,7 @@ const LoginMethod = EmberObject.extend({
|
|||||||
return this.message_override || I18n.t(`login.${this.name}.message`);
|
return this.message_override || I18n.t(`login.${this.name}.message`);
|
||||||
},
|
},
|
||||||
|
|
||||||
doLogin({ reconnect = false } = {}) {
|
doLogin({ reconnect = false, params = {} } = {}) {
|
||||||
if (this.customLogin) {
|
if (this.customLogin) {
|
||||||
this.customLogin();
|
this.customLogin();
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
@ -35,7 +35,15 @@ const LoginMethod = EmberObject.extend({
|
|||||||
let authUrl = Discourse.getURL(`/auth/${this.name}`);
|
let authUrl = Discourse.getURL(`/auth/${this.name}`);
|
||||||
|
|
||||||
if (reconnect) {
|
if (reconnect) {
|
||||||
authUrl += "?reconnect=true";
|
params["reconnect"] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const paramKeys = Object.keys(params);
|
||||||
|
if (paramKeys.length > 0) {
|
||||||
|
authUrl += "?";
|
||||||
|
authUrl += paramKeys
|
||||||
|
.map(k => `${encodeURIComponent(k)}=${encodeURIComponent(params[k])}`)
|
||||||
|
.join("&");
|
||||||
}
|
}
|
||||||
|
|
||||||
return LoginMethod.buildPostForm(authUrl).then(form => form.submit());
|
return LoginMethod.buildPostForm(authUrl).then(form => form.submit());
|
||||||
|
Loading…
Reference in New Issue
Block a user