mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
feat: login with github and if it is not a pdf file, set the width of chunkContainer to 100% (#106)
* feat: if it is not a pdf file, set the width of chunkContainer to 100% * feat: login with github
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import authorizationUtil from '@/utils/authorizationUtil';
|
||||
import { useState } from 'react';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useNavigate, useSearchParams } from 'umi';
|
||||
|
||||
export const useAuth = () => {
|
||||
const [isLogin, setIsLogin] = useState(
|
||||
@ -8,3 +9,28 @@ export const useAuth = () => {
|
||||
|
||||
return { isLogin };
|
||||
};
|
||||
|
||||
export const useLoginWithGithub = () => {
|
||||
const [currentQueryParameters, setSearchParams] = useSearchParams();
|
||||
const error = currentQueryParameters.get('error');
|
||||
const newQueryParameters: URLSearchParams = useMemo(
|
||||
() => new URLSearchParams(currentQueryParameters.toString()),
|
||||
[currentQueryParameters],
|
||||
);
|
||||
const navigate = useNavigate();
|
||||
|
||||
if (error) {
|
||||
navigate('/login');
|
||||
newQueryParameters.delete('error');
|
||||
setSearchParams(newQueryParameters);
|
||||
return;
|
||||
}
|
||||
|
||||
const auth = currentQueryParameters.get('auth');
|
||||
|
||||
if (auth) {
|
||||
authorizationUtil.setAuthorization(auth);
|
||||
newQueryParameters.delete('auth');
|
||||
setSearchParams(newQueryParameters);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user