Skip to content

Commit 681b9b7

Browse files
committed
Merge branch 'Andrea'
2 parents 134e06c + 87c3ebd commit 681b9b7

File tree

15 files changed

+79
-28
lines changed

15 files changed

+79
-28
lines changed

backend/gamelink/src/main/java/urjc/gamelink/Configuration/Security/RestSecurityConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ protected void configure(HttpSecurity http) throws Exception {
4949
http.antMatcher("/api/**");
5050

5151
// URLs that need authentication to access to it
52-
http.authorizeRequests().antMatchers(HttpMethod.POST, "/api/users/").hasAnyRole("ADMIN");
52+
http.authorizeRequests().antMatchers(HttpMethod.GET, "/api/users/").hasAnyRole("ADMIN");
53+
http.authorizeRequests().antMatchers(HttpMethod.POST, "/api/users/").not().hasAnyRole("USERO");
5354
http.authorizeRequests().antMatchers(HttpMethod.POST, "/api/users/**").hasAnyRole("USERO");
5455
http.authorizeRequests().antMatchers(HttpMethod.PUT, "/api/users/**").hasAnyRole("USERO");
5556
http.authorizeRequests().antMatchers(HttpMethod.DELETE, "/api/users/**").hasAnyRole("USERO");

backend/gamelink/src/main/java/urjc/gamelink/Controllers/UserRestController.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import org.hibernate.engine.jdbc.BlobProxy;
1414
import org.springframework.beans.factory.annotation.Autowired;
15+
import org.springframework.core.io.ClassPathResource;
1516
import org.springframework.core.io.InputStreamResource;
1617
import org.springframework.core.io.Resource;
1718
import org.springframework.http.HttpHeaders;
@@ -72,12 +73,21 @@ public ResponseEntity<Usero> getUser(@PathVariable long id) {
7273
// Creates a user
7374
@PostMapping("/")
7475
@ResponseStatus(HttpStatus.CREATED)
75-
public ResponseEntity<Usero> createUser(Usero user, @RequestParam String password) {
76+
public ResponseEntity<Usero> createUser(Usero user, @RequestParam String nick,
77+
@RequestParam String name, @RequestParam String lastName,
78+
@RequestParam String email, @RequestParam String password) throws IOException{
7679

80+
Resource image = new ClassPathResource("/static/Photos/defaultProfilePhoto.jpg");
81+
user.setImageFile(BlobProxy.generateProxy(image.getInputStream(), image.contentLength()));
82+
user.setImage(true);
7783
user.setEncodedPassword(passwordEncoder.encode(password));
7884
ArrayList<String> list = new ArrayList<>();
7985
list.add("USERO");
8086
user.setRoles(list);
87+
user.setNick(nick);
88+
user.setName(name);
89+
user.setLastName(lastName);
90+
user.setEmail(email);
8191
us.save(user);
8292
URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}").buildAndExpand(user.getId())
8393
.toUri();

backend/gamelink/src/main/resources/templates/signin.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ <h3 class="card-title text-center">Registro</h3>
5353
<span id="passwordMessage"></span>
5454
</div>
5555
<button onclick="location.href='/'; return false;">Cancelar</button>
56-
<button type="submit" (click)="logIn($event, nick.value, name.value, lastName.value, email.value, password.value)"
57-
class="btn btn-default">Login</button>
56+
<input id="createUserBtn" type="submit" value="Crear">
57+
<input type="hidden" name="_csrf" value="{{token}}"/>
5858
</form>
5959
<!-- Right after creating the button disable "Create User button"-->
6060
<script>
@@ -76,5 +76,6 @@ <h3 class="card-title text-center">Registro</h3>
7676
<!-- Bootstrap core JS-->
7777
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
7878
<!-- Core theme JS-->
79+
<script src="js/scripts.js"></script>
7980
</body>
80-
</html>
81+
</html>
File renamed without changes.

backend/gamelink/Dockerfile renamed to docker/Dockerfile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,27 @@ EXPOSE 8443
3434

3535
# Command that is executed when doing docker run
3636
CMD [ "java", "-jar", "gamelink-0.0.1-SNAPSHOT.jar" ]
37+
38+
#################################################
39+
# Base image for the application container
40+
#################################################
41+
42+
#Primera Etapa
43+
FROM node:10-alpine as build-step
44+
45+
RUN mkdir -p /app
46+
47+
WORKDIR /app
48+
49+
COPY package.json /app
50+
51+
RUN npm install
52+
53+
COPY . /app
54+
55+
RUN npm run build --prod
56+
57+
#Segunda Etapa
58+
FROM nginx:1.17.1-alpine
59+
#Si estas utilizando otra aplicacion cambia PokeApp por el nombre de tu app
60+
COPY --from=build-step /app/dist/PokeApp /usr/share/nginx/html
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
import { Component } from '@angular/core';
22
import { LoginService } from '../../services/login.service';
3+
import { Router } from '@angular/router';
34

45
@Component({
56
selector: 'login',
67
templateUrl: './login.component.html'
78
})
89
export class LoginComponent {
910

10-
constructor(public loginService: LoginService) { }
11+
constructor(private router: Router, public loginService: LoginService) { }
1112

1213
logIn(event: any, user: string, pass: string) {
1314

1415
event.preventDefault();
1516

1617
this.loginService.logIn(user, pass);
18+
this.router.navigate(['/home']);
1719
}
1820

1921
logOut() {
2022
this.loginService.logOut();
23+
this.router.navigate(['/home']);
2124
}
2225

2326
}

0 commit comments

Comments
 (0)