Merge pull request #83 from tloncorp/hm/fix-auth

auth: switch to new compatibility method
This commit is contained in:
Hunter Miller 2023-02-13 11:46:55 -06:00 committed by GitHub
commit 8a390c52a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,4 @@
import { preSig } from '@urbit/api';
import cookies from 'browser-cookies';
import React from 'react';
import ReactDOM from 'react-dom';
@ -20,7 +21,16 @@ function checkIfLoggedIn() {
const session = cookies.get(`urbauth-~${window.ship}`);
if (!session) {
authRedirect();
fetch('/~/name')
.then((res) => res.text())
.then((name) => {
if (name !== preSig(window.ship)) {
authRedirect();
}
})
.catch(() => {
authRedirect();
});
}
}