use the new login function
This commit is contained in:
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
|
||||
import { Button } from 'primereact/button';
|
||||
import { Card } from 'primereact/card';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Auth, Configuration, Session } from '../services';
|
||||
import { Auth, Session } from '../services';
|
||||
import { BackendReturnStatus } from '../types';
|
||||
|
||||
export const Login: React.FC = () => {
|
||||
@@ -24,24 +24,12 @@ export const Login: React.FC = () => {
|
||||
|
||||
if (loading) return <></>;
|
||||
|
||||
const redirectToVatsim = () => {
|
||||
const url = [
|
||||
Configuration.vatsim.authorizeUrl,
|
||||
`?client_id=${Configuration.vatsim.clientId}`,
|
||||
`&redirect_uri=${Configuration.resourceServer}/auth/vatsim`,
|
||||
`&response_type=code`,
|
||||
`&scope=full_name+vatsim_details`,
|
||||
`&approval_prompt=auto`,
|
||||
].join('');
|
||||
window.location.replace(url);
|
||||
}
|
||||
|
||||
const footer = (
|
||||
<span>
|
||||
<Button
|
||||
label='Login with VATSIM'
|
||||
className='p-button'
|
||||
onClick={redirectToVatsim}
|
||||
onClick={() => Auth.triggerLoginFlow()}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -9,6 +9,18 @@ import {
|
||||
} from '../types';
|
||||
|
||||
export class Auth {
|
||||
static triggerLoginFlow(): void {
|
||||
const url = [
|
||||
Configuration.vatsim.authorizeUrl,
|
||||
`?client_id=${Configuration.vatsim.clientId}`,
|
||||
`&redirect_uri=${Configuration.resourceServer}/auth/vatsim`,
|
||||
`&response_type=code`,
|
||||
`&scope=full_name+vatsim_details`,
|
||||
`&approval_prompt=auto`,
|
||||
].join('');
|
||||
window.location.replace(url);
|
||||
}
|
||||
|
||||
static async tokenIsValid(): Promise<BackendReturnStatus> {
|
||||
const token = Session.bearerToken();
|
||||
if (!token) return BackendReturnStatus.Unauthorized;
|
||||
|
||||
Reference in New Issue
Block a user