diff --git a/src/controllers/auth/login.js b/src/controllers/auth/login.js
index 4296b8bfb3..746384a64c 100644
--- a/src/controllers/auth/login.js
+++ b/src/controllers/auth/login.js
@@ -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) {
var card = dom.parentWithClass(e.target, "card");
var cardContent = card ? card.querySelector(".cardContent") : null;
@@ -183,6 +230,7 @@ define(["apphost", "appSettings", "dom", "connectionManager", "loading", "layout
Dashboard.navigate("forgotpassword.html");
});
view.querySelector(".btnCancel").addEventListener("click", showVisualForm);
+ view.querySelector(".btnQuick").addEventListener("click", loginQuickConnect);
view.querySelector(".btnManual").addEventListener("click", function () {
view.querySelector("#txtManualName").value = "";
showManualForm(view, true);
diff --git a/src/libraries/apiclient/apiclientcore.js b/src/libraries/apiclient/apiclientcore.js
index 557a4e1033..80be946a60 100644
--- a/src/libraries/apiclient/apiclientcore.js
+++ b/src/libraries/apiclient/apiclientcore.js
@@ -356,7 +356,28 @@ define(["events", "appStorage"], function(events, appStorage) {
instance.onAuthenticated ? instance.onAuthenticated(instance, result).then(afterOnAuthenticated) : afterOnAuthenticated()
}, 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 {
this.openWebSocket()
} catch (err) {
diff --git a/src/login.html b/src/login.html
index 8e48901c11..343b85906e 100644
--- a/src/login.html
+++ b/src/login.html
@@ -42,6 +42,10 @@
+
+