Skip to content

Commit

Permalink
Switch to new Bold authorization URL
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanNienhuis committed Jul 5, 2022
1 parent 1020120 commit bd9e399
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
11 changes: 7 additions & 4 deletions plugin/homebridge-ui/src/components/App/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { useEffect, useState } from 'react';
import QRCode from 'react-qr-code';

import AuthManager from '../../auth-manager';
import { Config } from '../../types';
import LegacyAuth from '../LegacyAuth';
import Page from '../Page';

import { Config } from '../../types';
import { AUTHORIZE_URL } from '../../const';

function App(): JSX.Element {
let [isAuthenticating, setAuthenticating] = useState(false);
let [showLegacyAuthentication, setLegacyAuthentication] = useState(false);
Expand Down Expand Up @@ -38,7 +41,7 @@ function App(): JSX.Element {
}

setStartingOAuth(false);
setOAuthURL(`https://boldsmartlock.com/app/authorize?response_type=code&client_id=HomeBridge&redirect_uri=${encodeURI(`${AuthManager.shared.callbackURL}`)}&state=${encodeURI(callbackId)}`);
setOAuthURL(`${AUTHORIZE_URL}?response_type=code&client_id=HomeBridge&redirect_uri=${encodeURI(`${AuthManager.shared.callbackURL}`)}&state=${encodeURI(callbackId)}`);

AuthManager.shared.once('oauthCallback', (result) => {
setResult({ ...result, legacyAuthentication: false });
Expand Down Expand Up @@ -126,13 +129,13 @@ function App(): JSX.Element {
] : oauthURL != null ?
[
{ icon: 'copy', action: () => navigator.clipboard.writeText(oauthURL || '') },
{ title: 'Open Bold', action: () => window.open(oauthURL) },
{ title: 'Log in', action: () => window.open(oauthURL) },
{ icon: 'qrcode', action: () => setShowingQRCode(!isShowingQRCode) }
] :
[]
} settingsAction={() => setInSettings(true)}>
<p>Log in using the Bold app by pressing the button below.</p>
<p className="text-muted fw-italic">Note: This must be done on a device with the Bold app installed. If this is not possible, use the <a href="#" onClick={() => setLegacyAuthentication(true)}>legacy authentication</a>.</p>
<p className="text-muted fw-italic">Alternatively: use the <a href="#" onClick={() => setLegacyAuthentication(true)}>legacy authentication</a>.</p>

{
isShowingQRCode && oauthURL != null ?
Expand Down
1 change: 1 addition & 0 deletions plugin/homebridge-ui/src/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const AUTHORIZE_URL = 'https://auth.boldsmartlock.com';
4 changes: 2 additions & 2 deletions plugin/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "homebridge-bold",
"displayName": "Homebridge Bold",
"version": "2.1.1",
"version": "2.1.2-beta1",
"description": "HomeKit support for the Bold Smart Locks.",
"main": "build/index.js",
"engines": {
Expand Down

0 comments on commit bd9e399

Please sign in to comment.