Actually make the login attempt to the well-known JMAP endpoint

This commit is contained in:
Eli Ribble 2024-08-27 10:48:49 -07:00
parent c6400d58d3
commit faca28f802
3 changed files with 28 additions and 11 deletions

View file

@ -1,5 +1,6 @@
import "./App.css";
import "bootstrap/dist/css/bootstrap.min.css";
import * as base64 from "base-64";
//import MailboxList from "./Mailbox";
import AuthModal from "./AuthModal";
@ -13,17 +14,18 @@ interface IAuth {
const App = () => {
const [state, setInternalState] = useState<IAuth | null>(null);
const fetchUserData = () => {
fetch("https://jsonplaceholder.typicode.com/users")
.then((response) => {
return response.json();
})
.then((data) => {
//setUsers(data)
});
};
const doLogin = (username: string, password: string) => {
alert("I be authin '" + username)
const doLogin = (email: string, password: string) => {
const domain = email.split("@")[1];
const well_known_url = "https://" + domain + "/.well-known/jmap"
let headers = new Headers();
headers.append("Authorization", "Basic " + base64.encode(email + ":" + password));
fetch(well_known_url, {
method: "GET",
headers: headers,
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error(error));
};
const loadAuth = () => {
const auth = localStorage.getItem("auth");