Revize 7a32656e
Přidáno uživatelem Jaroslav Hrubý před téměř 3 roky(ů)
Backend/Backend/Controllers/AuthController.cs | ||
---|---|---|
24 | 24 |
[HttpPost("/auth/login")] |
25 | 25 |
[ProducesResponseType((int) HttpStatusCode.OK, Type = typeof(LoginResponse))] |
26 | 26 |
[ProducesResponseType((int) HttpStatusCode.Forbidden)] |
27 |
public ActionResult<LoginResponse> Index([FromBody] LoginRequest loginData)
|
|
27 |
public ActionResult<LoginResponse> Login([FromBody] LoginRequest loginData)
|
|
28 | 28 |
{ |
29 | 29 |
try |
30 | 30 |
{ |
31 |
var loginResponse = authService.Index(loginData.Username, loginData.Password);
|
|
31 |
var loginResponse = authService.Login(loginData.Username, loginData.Password);
|
|
32 | 32 |
if (loginResponse == null) |
33 | 33 |
{ |
34 | 34 |
return Forbid(); |
Backend/Core/Services/AuthService/AuthService.cs | ||
---|---|---|
15 | 15 |
this.jwtUtils = jwtUtils; |
16 | 16 |
} |
17 | 17 |
|
18 |
public LoginResponse? Index(string username, string password)
|
|
18 |
public LoginResponse? Login(string username, string password)
|
|
19 | 19 |
{ |
20 | 20 |
var user = userService.CheckUsernamePassword(username, password); |
21 | 21 |
|
Backend/Core/Services/AuthService/IAuthService.cs | ||
---|---|---|
5 | 5 |
|
6 | 6 |
public interface IAuthService |
7 | 7 |
{ |
8 |
public LoginResponse? Index(string username, string password);
|
|
8 |
public LoginResponse? Login(string username, string password);
|
|
9 | 9 |
} |
webapp/components/annotation/AnnotationPanel.tsx | ||
---|---|---|
45 | 45 |
</Stack> |
46 | 46 |
</div> |
47 | 47 |
); |
48 |
} |
|
48 |
} |
webapp/components/navigation/AdminNavBar.tsx | ||
---|---|---|
12 | 12 |
faBookmark, |
13 | 13 |
} from '@fortawesome/free-solid-svg-icons'; |
14 | 14 |
|
15 |
const UserNavBar = () => {
|
|
15 |
const AdminNavBar = () => {
|
|
16 | 16 |
const router = useRouter(); |
17 | 17 |
const { logout } = useContext(LoggedUserContext); |
18 | 18 |
const { SubMenu } = Menu; |
... | ... | |
53 | 53 |
); |
54 | 54 |
}; |
55 | 55 |
|
56 |
export default UserNavBar; |
|
56 |
export default AdminNavBar; |
webapp/components/types/Auth.ts | ||
---|---|---|
1 |
import { AppProps } from 'next/app'; |
|
2 |
import { ERole } from '../../api'; |
|
3 |
|
|
4 |
export type SecuredComponent = AppProps['Component'] & { |
|
5 |
auth: ComponentAuth; |
|
6 |
}; |
|
7 |
|
|
8 |
export class ComponentAuth { |
|
9 |
minRole: ERole | null; |
|
10 |
|
|
11 |
constructor(minRole: ERole | null = null) { |
|
12 |
this.minRole = minRole; |
|
13 |
} |
|
14 |
} |
webapp/components/types/auth.ts | ||
---|---|---|
1 |
import { AppProps } from 'next/app'; |
|
2 |
import { ERole } from '../../api'; |
|
3 |
|
|
4 |
export type SecuredComponent = AppProps['Component'] & { |
|
5 |
auth: ComponentAuth; |
|
6 |
}; |
|
7 |
|
|
8 |
export class ComponentAuth { |
|
9 |
minRole: ERole | null; |
|
10 |
|
|
11 |
constructor(minRole: ERole | null = null) { |
|
12 |
this.minRole = minRole; |
|
13 |
} |
|
14 |
} |
webapp/layouts/LoginLayout.tsx | ||
---|---|---|
1 |
import React from 'react'; |
|
1 | 2 |
import logo from '/public/usp-logo.svg'; |
2 | 3 |
import Image from 'next/image'; |
3 | 4 |
import styles from '/styles/Login.module.scss'; |
4 | 5 |
import { Col, Container, Row, Stack } from 'react-bootstrap'; |
5 |
import React from 'react'; |
|
6 | 6 |
|
7 | 7 |
/** |
8 | 8 |
* Creates a layout of a login screen. |
webapp/pages/_app.tsx | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import type { AppProps } from 'next/app'; |
6 | 6 |
import Head from 'next/head'; |
7 |
import { SecuredComponent } from '../components/types/auth';
|
|
7 |
import { SecuredComponent } from '../components/types/Auth';
|
|
8 | 8 |
import LoggedUserProvider from '../contexts/LoggedUserContext'; |
9 | 9 |
import Auth from '../components/common/Auth'; |
10 | 10 |
|
webapp/pages/documents/annotator/index.tsx | ||
---|---|---|
4 | 4 |
import { useUnauthRedirect } from '../../../hooks'; |
5 | 5 |
import { useRouter } from 'next/router'; |
6 | 6 |
import { Layout, Typography } from 'antd'; |
7 |
import UserNavBar from '../../../components/navigation/userNavBar';
|
|
7 |
import UserNavBar from '../../../components/navigation/UserNavBar';
|
|
8 | 8 |
import { faFileLines } from '@fortawesome/free-solid-svg-icons'; |
9 | 9 |
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
10 | 10 |
import { LoggedUserContext } from '../../../contexts/LoggedUserContext'; |
Také k dispozici: Unified diff
Refactoring