Merge pull request #36 from liosha84/33-show-user-tutorials-in-user-tutorials
33 show user tutorials in user tutorials
This commit is contained in:
@@ -65,7 +65,13 @@
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
"with": "src/environments/environment.development.ts"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
|
||||
@@ -18,9 +18,11 @@ import 'prismjs';
|
||||
import 'prismjs/components/prism-typescript.min.js';
|
||||
import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
|
||||
import 'prismjs/plugins/line-highlight/prism-line-highlight.js';
|
||||
import {authInterceptorProviders} from './helpers/auth.interceptor';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
authInterceptorProviders,
|
||||
provideBrowserGlobalErrorListeners(),
|
||||
provideAnimations(),
|
||||
provideZoneChangeDetection({ eventCoalescing: true }),
|
||||
|
||||
@@ -3,6 +3,9 @@ import {Tutorial} from '../../models/tutorial.model';
|
||||
import {TutorialService} from '../../services/tutorial.service';
|
||||
import {MatCard, MatCardContent, MatCardHeader} from '@angular/material/card';
|
||||
import {MarkdownComponent} from 'ngx-markdown';
|
||||
import {authInterceptorProviders} from '../../helpers/auth.interceptor';
|
||||
import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from '@angular/common/http';
|
||||
import {CustomHttpInterceptor} from '../../helpers/custom-http-interceptor';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tutorials.component',
|
||||
@@ -14,7 +17,12 @@ import {MarkdownComponent} from 'ngx-markdown';
|
||||
],
|
||||
templateUrl: './tutorials.component.html',
|
||||
styleUrl: './tutorials.component.scss',
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
providers: [authInterceptorProviders,{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: CustomHttpInterceptor,
|
||||
multi: true
|
||||
}],
|
||||
})
|
||||
export class TutorialsComponent {
|
||||
tutorials?: Tutorial[];
|
||||
|
||||
@@ -12,15 +12,25 @@ export class AuthInterceptor implements HttpInterceptor {
|
||||
constructor(private token: TokenStorageService) { }
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
let authReq = req;
|
||||
|
||||
|
||||
req = req.clone({
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
return next.handle(req);
|
||||
|
||||
|
||||
/*let authReq = req;
|
||||
const token = this.token.getToken();
|
||||
if (token != null) {
|
||||
authReq = req.clone({ headers: req.headers.set(TOKEN_HEADER_KEY, 'Bearer ' + token) });
|
||||
}
|
||||
return next.handle(authReq);
|
||||
return next.handle(authReq);*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const authInterceptorProviders = [
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
|
||||
];
|
||||
];
|
||||
|
||||
@@ -18,6 +18,9 @@ import {MatMenu, MatMenuItem, MatMenuTrigger} from '@angular/material/menu';
|
||||
import {MatTooltip} from '@angular/material/tooltip';
|
||||
import {DialogSignupComponent} from '../../components/dialog-signup.component/dialog-signup.component';
|
||||
import {MatLabel} from '@angular/material/input';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
import { environment } from '../../../environments/environment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main.component',
|
||||
@@ -62,12 +65,13 @@ export class MainComponent implements OnInit{
|
||||
|
||||
eventBusSub?: Subscription;
|
||||
|
||||
private environment = environment;
|
||||
|
||||
private storageService: TokenStorageService = inject(TokenStorageService);
|
||||
private authService: AuthService = inject(AuthService);
|
||||
private eventBusService: EventBusService = inject(EventBusService);
|
||||
|
||||
constructor(private router: Router) {
|
||||
constructor(private router: Router,private http: HttpClient) {
|
||||
|
||||
}
|
||||
goToHome() {
|
||||
@@ -136,6 +140,8 @@ export class MainComponent implements OnInit{
|
||||
console.log(res);
|
||||
this.storageService.clean();
|
||||
|
||||
//window.location.reload();
|
||||
this.router.navigate([environment.default_page]);
|
||||
window.location.reload();
|
||||
},
|
||||
error: err => {
|
||||
@@ -167,8 +173,9 @@ export class MainComponent implements OnInit{
|
||||
this.dialogLoginData = result;
|
||||
|
||||
this.authService.login(this.dialogLoginData.username, this.dialogLoginData.password).subscribe(
|
||||
data => {
|
||||
this.storageService.saveToken(data.accessToken);
|
||||
data => {
|
||||
|
||||
//this.storageService.saveToken(data.token);
|
||||
this.storageService.saveUser(data);
|
||||
|
||||
this.isLoggedIn = true;
|
||||
|
||||
@@ -4,11 +4,12 @@ import {mainRouting} from './main.routing';
|
||||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
import {HTTP_INTERCEPTORS} from '@angular/common/http';
|
||||
import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from '@angular/common/http';
|
||||
import {CustomHttpInterceptor} from '../helpers/custom-http-interceptor';
|
||||
import {AngularImageViewerModule} from '@hreimer/angular-image-viewer';
|
||||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
import {authInterceptorProviders} from '../helpers/auth.interceptor';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
@@ -22,7 +23,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||
|
||||
],
|
||||
exports: [RouterModule],
|
||||
providers: [{
|
||||
providers: [authInterceptorProviders,provideHttpClient(withInterceptorsFromDi()),{
|
||||
provide: HTTP_INTERCEPTORS,
|
||||
useClass: CustomHttpInterceptor,
|
||||
multi: true
|
||||
|
||||
@@ -19,6 +19,8 @@ export class AuthService {
|
||||
username,
|
||||
password
|
||||
}, httpOptions);
|
||||
|
||||
|
||||
}
|
||||
|
||||
register(username: string, email: string, password: string): Observable<any> {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Tutorial } from '../models/tutorial.model';
|
||||
import {text} from 'node:stream/consumers';
|
||||
|
||||
const baseUrl = 'http://localhost:8080/api/tutorials';
|
||||
|
||||
@@ -16,6 +17,8 @@ export class TutorialService {
|
||||
return this.http.get<Tutorial[]>(baseUrl);
|
||||
}
|
||||
|
||||
|
||||
|
||||
get(id: any): Observable<Tutorial> {
|
||||
return this.http.get(`${baseUrl}/${id}`);
|
||||
}
|
||||
@@ -39,4 +42,4 @@ export class TutorialService {
|
||||
findByTitle(title: any): Observable<Tutorial[]> {
|
||||
return this.http.get<Tutorial[]>(`${baseUrl}?title=${title}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-3
@@ -1,6 +1,26 @@
|
||||
<p>tutorials-list.component works!</p>
|
||||
<mat-list role="list">
|
||||
<mat-list-item role="listitem">Item 1</mat-list-item>
|
||||
<mat-list-item role="listitem">Item 2</mat-list-item>
|
||||
<mat-list-item role="listitem">Item 3</mat-list-item>
|
||||
@for (tutorial of tutorials; track tutorial) {
|
||||
<!--
|
||||
<mat-list-item role="listitem">
|
||||
{{tutorial.title}}
|
||||
|
||||
|
||||
<span class="spacer"></span>
|
||||
<button mat-button>
|
||||
<mat-icon>edit</mat-icon>
|
||||
</button>
|
||||
<button mat-button>
|
||||
<mat-icon>delete</mat-icon>
|
||||
</button>
|
||||
</mat-list-item>-->
|
||||
<mat-option >
|
||||
<div style="display:flex; justify-content: space-between">
|
||||
<span>{{tutorial.title}}</span>
|
||||
<span></span>
|
||||
<span (click)="deleteOption($event, tutorial)">X</span>
|
||||
</div>
|
||||
</mat-option>
|
||||
}
|
||||
|
||||
</mat-list>
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
.spacer{
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
+33
-2
@@ -1,15 +1,46 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {Component, CUSTOM_ELEMENTS_SCHEMA} from '@angular/core';
|
||||
import {MatList, MatListItem} from '@angular/material/list';
|
||||
import {Tutorial} from '../../models/tutorial.model';
|
||||
import {TutorialService} from '../../services/tutorial.service';
|
||||
import {UserApiService} from '../user-api.service';
|
||||
import {MatButton} from '@angular/material/button';
|
||||
import {MatLine, MatOption} from '@angular/material/core';
|
||||
import {MatIcon} from '@angular/material/icon';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tutorials-list.component',
|
||||
imports: [
|
||||
MatList,
|
||||
MatListItem
|
||||
MatListItem,
|
||||
MatLine,
|
||||
MatButton,
|
||||
MatIcon,
|
||||
MatOption
|
||||
],
|
||||
schemas:[CUSTOM_ELEMENTS_SCHEMA],
|
||||
templateUrl: './tutorials-list.component.html',
|
||||
styleUrl: './tutorials-list.component.scss'
|
||||
})
|
||||
export class TutorialsListComponent {
|
||||
tutorials?: Tutorial[];
|
||||
|
||||
constructor(private userApiService: UserApiService) {
|
||||
this.retrieveTutorials();
|
||||
}
|
||||
|
||||
retrieveTutorials(): void {
|
||||
this.userApiService.getUserAllTutorials()
|
||||
.subscribe(
|
||||
data => {
|
||||
this.tutorials = data;
|
||||
console.log(data);
|
||||
},
|
||||
error => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
|
||||
deleteOption($event: MouseEvent, option: any) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserApiService } from './user-api.service';
|
||||
|
||||
describe('UserApiService', () => {
|
||||
let service: UserApiService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UserApiService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {Observable} from 'rxjs';
|
||||
import {Tutorial} from '../models/tutorial.model';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserApiService {
|
||||
baseUrl = 'http://localhost:8080/api/user';
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
|
||||
}
|
||||
|
||||
getUserAllTutorials(): Observable<Tutorial[]> {
|
||||
return this.http.get<Tutorial[]>(`${this.baseUrl}/tutorials`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
default_page: 'main/generate-image'
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
export const environment = {
|
||||
default_page: 'main/generate-image'
|
||||
};
|
||||
@@ -62,6 +62,9 @@ if (isMainModule(import.meta.url)) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Request handler used by the Angular CLI (for dev-server and during build) or Firebase Cloud Functions.
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,8 @@ import com.jambotronGroup.jambotron.repository.UserRepository;
|
||||
import com.jambotronGroup.jambotron.security.jwt.JwtUtils;
|
||||
import com.jambotronGroup.jambotron.security.services.UserDetailsImpl;
|
||||
import jakarta.validation.Valid;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.ResponseCookie;
|
||||
@@ -34,6 +36,8 @@ import java.util.stream.Collectors;
|
||||
@RestController
|
||||
@RequestMapping("/api/auth")
|
||||
public class AuthController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuthController.class);
|
||||
@Autowired
|
||||
AuthenticationManager authenticationManager;
|
||||
|
||||
@@ -65,12 +69,16 @@ public class AuthController {
|
||||
.map(item -> item.getAuthority())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
logger.info("User {} authenticated successfully with roles: {}", userDetails.getUsername(), roles);
|
||||
|
||||
return ResponseEntity.ok().header(HttpHeaders.SET_COOKIE, jwtCookie.toString())
|
||||
.body(new UserInfoResponse(
|
||||
userDetails.getId(),
|
||||
userDetails.getUsername(),
|
||||
userDetails.getEmail(),
|
||||
roles));
|
||||
roles,
|
||||
jwtCookie.toString()
|
||||
));
|
||||
}
|
||||
|
||||
@PostMapping("/signup")
|
||||
|
||||
@@ -2,10 +2,20 @@ package com.jambotronGroup.jambotron.controllers;
|
||||
|
||||
|
||||
import com.jambotronGroup.jambotron.model.Tutorial;
|
||||
import com.jambotronGroup.jambotron.model.User;
|
||||
import com.jambotronGroup.jambotron.repository.TutorialRepository;
|
||||
import com.jambotronGroup.jambotron.repository.UserRepository;
|
||||
import com.jambotronGroup.jambotron.security.AuthenticationFacade;
|
||||
import com.jambotronGroup.jambotron.security.services.UserDetailsImpl;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -19,18 +29,70 @@ import java.util.Optional;
|
||||
@RequestMapping("/api")
|
||||
public class TutorialController {
|
||||
|
||||
@Autowired
|
||||
AuthenticationFacade authenticationFacade;
|
||||
@Autowired
|
||||
UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
TutorialRepository tutorialRepository;
|
||||
|
||||
@GetMapping("/user/tutorials")
|
||||
public ResponseEntity<List<Tutorial>> getUserTutorials(@RequestParam(required = false) String title) {
|
||||
try {
|
||||
List<Tutorial> tutorials = new ArrayList<Tutorial>();
|
||||
|
||||
User user = userRepository.findById(authenticationFacade.getUserDetails().getId()).get();
|
||||
|
||||
|
||||
if(title == null){
|
||||
// If no title is provided, return all tutorials for the user
|
||||
tutorialRepository.findByUserId(user.getId()).forEach(tutorials::add);
|
||||
} else {
|
||||
// If a title is provided, filter tutorials by user and title
|
||||
tutorialRepository.findByUserIdAndTitle(user.getId(), title).forEach(tutorials::add);
|
||||
}
|
||||
|
||||
if (tutorials.isEmpty()) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
return new ResponseEntity<>(tutorials, HttpStatus.OK);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/tutorials")
|
||||
public ResponseEntity<List<Tutorial>> getAllTutorials(@RequestParam(required = false) String title) {
|
||||
try {
|
||||
List<Tutorial> tutorials = new ArrayList<Tutorial>();
|
||||
|
||||
if (title == null)
|
||||
tutorialRepository.findAll().forEach(tutorials::add);
|
||||
else
|
||||
tutorialRepository.findByTitleContaining(title).forEach(tutorials::add);
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
String name = authenticationFacade.getAuthentication().getName();
|
||||
|
||||
User user = userRepository.findById(((UserDetailsImpl)userDetails).getId()).get();
|
||||
if (user.getRoles().stream().anyMatch(role -> role.getName().name().equals("ROLE_ADMIN"))) {
|
||||
if (title == null)
|
||||
tutorialRepository.findAll().forEach(tutorials::add);
|
||||
else
|
||||
tutorialRepository.findByTitleContaining(title).forEach(tutorials::add);
|
||||
|
||||
} else {
|
||||
|
||||
// If the user is not an admin, filter tutorials by user
|
||||
tutorialRepository.findByUserId(user.getId()).forEach(tutorials::add);
|
||||
if (tutorials.isEmpty()) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
return new ResponseEntity<>(tutorials, HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (tutorials.isEmpty()) {
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
@@ -55,9 +117,15 @@ public class TutorialController {
|
||||
|
||||
@PostMapping("/tutorials")
|
||||
public ResponseEntity<Tutorial> createTutorial(@RequestBody Tutorial tutorial) {
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
|
||||
User user = userRepository.findById(((UserDetailsImpl)userDetails).getId()).get();
|
||||
|
||||
try {
|
||||
Tutorial _tutorial = tutorialRepository
|
||||
.save(new Tutorial(tutorial.getTitle(), tutorial.getDescription(), false));
|
||||
.save(new Tutorial(tutorial.getTitle(), tutorial.getDescription(), false, user));
|
||||
return new ResponseEntity<>(_tutorial, HttpStatus.CREATED);
|
||||
} catch (Exception e) {
|
||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
|
||||
@@ -21,14 +21,19 @@ public class Tutorial {
|
||||
@Column(name = "published")
|
||||
private boolean published;
|
||||
|
||||
@ManyToOne(fetch = FetchType.LAZY, optional = false)
|
||||
@JoinColumn(name = "userID", nullable = false)
|
||||
private User user;
|
||||
|
||||
public Tutorial() {
|
||||
|
||||
}
|
||||
|
||||
public Tutorial(String title, String description, boolean published) {
|
||||
public Tutorial(String title, String description, boolean published, User user) {
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.published = published;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
|
||||
@@ -10,11 +10,14 @@ public class UserInfoResponse {
|
||||
private String email;
|
||||
private List<String> roles;
|
||||
|
||||
public UserInfoResponse(Long id, String username, String email, List<String> roles) {
|
||||
private String token;
|
||||
|
||||
public UserInfoResponse(Long id, String username, String email, List<String> roles, String token) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.roles = roles;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -44,4 +47,12 @@ public class UserInfoResponse {
|
||||
public List<String> getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface TutorialRepository extends JpaRepository<Tutorial, Long> {
|
||||
|
||||
List<Tutorial> findByUserId(Long userId);
|
||||
List<Tutorial> findByUserIdAndTitle(Long userId, String title);
|
||||
List<Tutorial> findByPublished(boolean published);
|
||||
List<Tutorial> findByTitleContaining(String title);
|
||||
}
|
||||
@@ -9,6 +9,8 @@ import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
|
||||
|
||||
Optional<User> findByUsername(String username);
|
||||
|
||||
Boolean existsByUsername(String username);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.jambotronGroup.jambotron.security;
|
||||
|
||||
import com.jambotronGroup.jambotron.security.services.UserDetailsImpl;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AuthenticationFacade implements IAuthenticationFacade {
|
||||
|
||||
@Override
|
||||
public Authentication getAuthentication() {
|
||||
|
||||
return SecurityContextHolder.getContext().getAuthentication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetailsImpl getUserDetails() {
|
||||
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
|
||||
|
||||
return (UserDetailsImpl) userDetails;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.jambotronGroup.jambotron.security;
|
||||
|
||||
import com.jambotronGroup.jambotron.security.services.UserDetailsImpl;
|
||||
import org.springframework.security.core.Authentication;
|
||||
|
||||
public interface IAuthenticationFacade {
|
||||
Authentication getAuthentication();
|
||||
|
||||
UserDetailsImpl getUserDetails();
|
||||
}
|
||||
@@ -43,10 +43,7 @@ public class WebSecurityConfig implements WebMvcConfigurer {// extends WebSecuri
|
||||
// authenticationManagerBuilder.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// Do not add any mappings to enable complete disabling of CORS.
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public DaoAuthenticationProvider authenticationProvider() {
|
||||
@@ -118,7 +115,8 @@ public class WebSecurityConfig implements WebMvcConfigurer {// extends WebSecuri
|
||||
|
||||
.requestMatchers("/main/**").permitAll()
|
||||
.requestMatchers("/api/test/**").permitAll()
|
||||
.requestMatchers("/api/tutorials").permitAll()
|
||||
|
||||
//.requestMatchers("/api/tutorials").hasRole("ADMIN")
|
||||
|
||||
.requestMatchers("/api/zhipuai/image/**").permitAll()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user