Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect home server from matrix id #810

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4de8ab4
Adding the functionnality to use his own matrix id (@username:server.…
Kaki-In Jul 21, 2022
254cea5
Added some forgot changes
Kaki-In Jul 21, 2022
968dbac
Removed a console.log
Kaki-In Jul 21, 2022
05c3afb
Added some forgot changes
Kaki-In Jul 21, 2022
1298d43
Removed a console.dir
Kaki-In Jul 21, 2022
dcb1534
Fixed minor bug
Kaki-In Jul 21, 2022
bd29e09
Fixed the problem of having given a bad password/username
Kaki-In Jul 21, 2022
d8c6847
Improve the connection frame actualisation
Kaki-In Jul 22, 2022
28785d9
Fixed a bug that always showed the password and login views when load…
Kaki-In Jul 22, 2022
d75c937
New corrections (from base of #810 pull request commentaries) :
Kaki-In Jul 25, 2022
c7c32a6
Update about the serverName constant : missing the result id (from th…
Kaki-In Jul 25, 2022
17730e8
Detected inattention mistake.
Kaki-In Jul 25, 2022
5542335
Merge branch 'vector-im:master' into detect-hs-from-mxid
Kaki-In Jul 25, 2022
35e830b
Resolved the comments at https://github.com/vector-im/hydrogen-web/pu…
Kaki-In Jul 26, 2022
acd1eea
Fixed an error while writing boolean
Kaki-In Jul 27, 2022
2b1805b
Canceled the indenting modification.
Kaki-In Jul 27, 2022
d47a552
Merge branch 'master' into detect-hs-from-mxid
Kaki-In Jul 29, 2022
a060591
Resolved morge conflict with LoginViewmodel
Kaki-In Jul 29, 2022
af3f900
Merge branch 'vector-im:master' into detect-hs-from-mxid
Kaki-In Jul 29, 2022
46c2822
Fixed last checked on https://github.com/vector-im/hydrogen-web/pull/810
Kaki-In Jul 29, 2022
d65a5a3
Merge branch 'vector-im:master' into detect-hs-from-mxid
Kaki-In Jul 29, 2022
51acbf5
Merge branch 'vector-im:master' into detect-hs-from-mxid
Kaki-In Jul 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
New corrections (from base of #810 pull request commentaries) :
 - fix methods miss;
 - corrected some identation mistakes.
Kaki-In committed Jul 25, 2022
commit d75c937c28096986fb82928fb723c87130220693
12 changes: 6 additions & 6 deletions src/domain/login/LoginViewModel.js
Original file line number Diff line number Diff line change
@@ -166,8 +166,8 @@ export class LoginViewModel extends ViewModel {
}

updateLoginOptions() {
this._passwordLoginViewModel?.setLoginOptions(this._loginOptions);
}
this._passwordLoginViewModel?.setLoginOptions(this._loginOptions);
}

async setHomeserver(newHomeserver) {
this._homeserver = newHomeserver;
@@ -192,7 +192,7 @@ export class LoginViewModel extends ViewModel {
}
}
this._abortHomeserverQueryTimeout = this.disposeTracked(this._abortHomeserverQueryTimeout);
return this.queryHomeserver();
await this.queryHomeserver();
}

async queryHomeserver() {
@@ -229,7 +229,7 @@ export class LoginViewModel extends ViewModel {
this._abortQueryOperation = this.disposeTracked(this._abortQueryOperation);
this.emitChange("isFetchingLoginOptions");
}
this.updateLoginOptions();
this.updateLoginOptions();
if (this._loginOptions) {
if (this._loginOptions.sso && !this._startSSOLoginViewModel) { this._showSSOLogin(); }
if (!this._loginOptions.sso && this._startSSOLoginViewModel) { this._hideSSOLogin(); }
@@ -241,8 +241,8 @@ export class LoginViewModel extends ViewModel {
}
else {
this._showError(`Could not query login methods supported by ${this.homeserver}`);
this._hideSSOLogin();
this._hidePasswordLogin();
this._hideSSOLogin();
this._hidePasswordLogin();
}
this._passwordLoginViewModel?.setEnabled(false);
}
47 changes: 24 additions & 23 deletions src/domain/login/PasswordLoginViewModel.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ export class PasswordLoginViewModel extends ViewModel {
this._loginOptions = loginOptions;
this._attemptLogin = attemptLogin;
this._isBusy = false;
this._enabled = true;
this._enabled = true;
this._errorMessage = "";
}

@@ -43,32 +43,33 @@ export class PasswordLoginViewModel extends ViewModel {
}

setLoginOptions(loginOptions) {
this._loginOptions = loginOptions;
}
setEnabled(enabled) {
this._enabled = enabled;
this._loginOptions = loginOptions;
}
setEnabled(enabled) {
this._enabled = enabled;
this.emitChange("isEnabled");
}
}

async parseUsernameLogin (login) {
Kaki-In marked this conversation as resolved.
Show resolved Hide resolved
Kaki-In marked this conversation as resolved.
Show resolved Hide resolved
if ((login.match(/@/g) || []).length == 1 && (login.match(/:/g) || []).length == 1 && (login.match(/\./g) || []).length) {
bwindels marked this conversation as resolved.
Show resolved Hide resolved
if (login.indexOf("@") == 0 && login.indexOf("@") < login.indexOf(":") && login.indexOf(":") < login.indexOf(".")) {
if (this._loginOptions.homeserver != login.substring(login.indexOf(":") + 1)) {await await this._options.setHomeserver(login.substring(login.indexOf(":") + 1));}
return login.substring(1, login.indexOf(":"));
const serverName = login.match(/@.*:(.+)/);
if (this._loginOptions.homeserver != serverName) {await this._options.setHomeserver(serverName);}
return serverName;
}
}
return login;
}

async login(username, password) {
this.setBusy(true);
let usernameChanged = username;
username = await this.parseUsernameLogin(username);
if (!this._loginOptions) {
return;
}
usernameChanged = usernameChanged !== username;
this.setBusy(true);
let usernameChanged = username;
username = await this.parseUsernameLogin(username);
if (!this._loginOptions) {
return;
}
usernameChanged = usernameChanged !== username;
this._showError("");
const status = await this._attemptLogin(this._loginOptions.password(username, password));
let error = "";
@@ -84,13 +85,13 @@ export class PasswordLoginViewModel extends ViewModel {
break;
}
if (error) {
if (usernameChanged) {
console.log(error);
this._options.showConnectionError(error);
} else {
this._showError(error);
}
if (usernameChanged) {
console.log(error);
this._options.showConnectionError(error);
Kaki-In marked this conversation as resolved.
Show resolved Hide resolved
} else {
this._showError(error);
}
}
this.setBusy(false);
this.setBusy(false);
}
}