mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add quick connect
This commit is contained in:
parent
0ca38fb37c
commit
b43adb7406
3 changed files with 74 additions and 1 deletions
|
@ -150,6 +150,53 @@ define(["apphost", "appSettings", "dom", "connectionManager", "loading", "layout
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loginQuickConnect() {
|
||||||
|
var apiClient = getApiClient();
|
||||||
|
var identifier = ""
|
||||||
|
var interval = 0;
|
||||||
|
var friendlyName = "test";
|
||||||
|
$.get('/QuickConnect/Initiate?FriendlyName=' + friendlyName).then(json => {
|
||||||
|
if (!json.Secret || !json.Code) {
|
||||||
|
Dashboard.alert({
|
||||||
|
message: json.Error,
|
||||||
|
title: "Error"
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dashboard.alert({
|
||||||
|
message: "Authorize request " + json.Code + " to continue",
|
||||||
|
title: "Quick Connect Code"
|
||||||
|
});
|
||||||
|
|
||||||
|
loading.show();
|
||||||
|
|
||||||
|
identifier = json.Secret;
|
||||||
|
interval = setInterval(() => {
|
||||||
|
$.get('/QuickConnect/Connect?Secret=' + identifier).then(x => {
|
||||||
|
if(x.Authenticated) {
|
||||||
|
apiClient.quickConnect(x.Authentication).then((result) => {
|
||||||
|
var user = result.User;
|
||||||
|
var serverId = getParameterByName("serverid");
|
||||||
|
var newUrl;
|
||||||
|
|
||||||
|
if (user.Policy.IsAdministrator && !serverId) {
|
||||||
|
newUrl = "dashboard.html";
|
||||||
|
} else {
|
||||||
|
newUrl = "home.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.hide();
|
||||||
|
Dashboard.onServerChanged(user.Id, result.AccessToken, apiClient);
|
||||||
|
Dashboard.navigate(newUrl);
|
||||||
|
clearInterval(interval);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
view.querySelector("#divUsers").addEventListener("click", function (e) {
|
view.querySelector("#divUsers").addEventListener("click", function (e) {
|
||||||
var card = dom.parentWithClass(e.target, "card");
|
var card = dom.parentWithClass(e.target, "card");
|
||||||
var cardContent = card ? card.querySelector(".cardContent") : null;
|
var cardContent = card ? card.querySelector(".cardContent") : null;
|
||||||
|
@ -183,6 +230,7 @@ define(["apphost", "appSettings", "dom", "connectionManager", "loading", "layout
|
||||||
Dashboard.navigate("forgotpassword.html");
|
Dashboard.navigate("forgotpassword.html");
|
||||||
});
|
});
|
||||||
view.querySelector(".btnCancel").addEventListener("click", showVisualForm);
|
view.querySelector(".btnCancel").addEventListener("click", showVisualForm);
|
||||||
|
view.querySelector(".btnQuick").addEventListener("click", loginQuickConnect);
|
||||||
view.querySelector(".btnManual").addEventListener("click", function () {
|
view.querySelector(".btnManual").addEventListener("click", function () {
|
||||||
view.querySelector("#txtManualName").value = "";
|
view.querySelector("#txtManualName").value = "";
|
||||||
showManualForm(view, true);
|
showManualForm(view, true);
|
||||||
|
|
|
@ -356,7 +356,28 @@ define(["events", "appStorage"], function(events, appStorage) {
|
||||||
instance.onAuthenticated ? instance.onAuthenticated(instance, result).then(afterOnAuthenticated) : afterOnAuthenticated()
|
instance.onAuthenticated ? instance.onAuthenticated(instance, result).then(afterOnAuthenticated) : afterOnAuthenticated()
|
||||||
}, reject)
|
}, reject)
|
||||||
})
|
})
|
||||||
}, ApiClient.prototype.ensureWebSocket = function() {
|
}, ApiClient.prototype.quickConnect = function (token) {
|
||||||
|
if (!token) return Promise.reject();
|
||||||
|
var url = this.getUrl("Users/AuthenticateWithQuickConnect"),
|
||||||
|
instance = this;
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
var postData = {
|
||||||
|
Token: token
|
||||||
|
};
|
||||||
|
instance.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: url,
|
||||||
|
data: JSON.stringify(postData),
|
||||||
|
dataType: "json",
|
||||||
|
contentType: "application/json"
|
||||||
|
}).then(function(result) {
|
||||||
|
var afterOnAuthenticated = function() {
|
||||||
|
redetectBitrate(instance), resolve(result)
|
||||||
|
};
|
||||||
|
instance.onAuthenticated ? instance.onAuthenticated(instance, result).then(afterOnAuthenticated) : afterOnAuthenticated()
|
||||||
|
}, reject)
|
||||||
|
})
|
||||||
|
}, ApiClient.prototype.ensureWebSocket = function() {
|
||||||
if (!this.isWebSocketOpenOrConnecting() && this.isWebSocketSupported()) try {
|
if (!this.isWebSocketOpenOrConnecting() && this.isWebSocketSupported()) try {
|
||||||
this.openWebSocket()
|
this.openWebSocket()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -43,6 +43,10 @@
|
||||||
<span>${ButtonManualLogin}</span>
|
<span>${ButtonManualLogin}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<button is="emby-button" type="button" class="raised cancel block btnQuick">
|
||||||
|
<span>Use Quick Connect</span>
|
||||||
|
</button>
|
||||||
|
|
||||||
<button is="emby-button" type="button" class="raised cancel block btnForgotPassword">
|
<button is="emby-button" type="button" class="raised cancel block btnForgotPassword">
|
||||||
<span>${ButtonForgotPassword}</span>
|
<span>${ButtonForgotPassword}</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue