Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
Expand Down Expand Up @@ -40,9 +41,11 @@ public class PessoaController {
return obterListaCompleta();
}

@GetMapping("/{user}")
public List<Pessoa>list(@PathVariable String user){
return null;
@GetMapping("/{id}")
public Optional<Pessoa> list(@PathVariable int id){

return pessoaRepository.findById(id);

}

private List<Pessoa> obterListaCompleta() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,20 @@ public class Login extends MaturidadeNivel3Richardson {
private String senha;
private boolean admin;
private boolean enterprise;
private Integer pessoa_id;

public Login() {
super();
}

public Login(Integer id, String user, String senha, boolean admin, boolean enterprise) {
public Login(Integer id, String user, String senha, boolean admin, boolean enterprise, Integer pessoa_id) {
super();
this.id = id;
this.user = user;
this.senha = senha;
this.admin = admin;
this.enterprise = enterprise;
this.pessoa_id = pessoa_id;
}

public Integer getId() {
Expand Down Expand Up @@ -69,6 +71,14 @@ public boolean isEnterprise() {

public void setEnterprise(boolean enterprise) {
this.enterprise = enterprise;
}

public Integer getPessoa_id() {
return pessoa_id;
}

public void setPessoa_id(Integer pessoa_id) {
this.pessoa_id = pessoa_id;
}

}
17 changes: 10 additions & 7 deletions frontend/main/src/app/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ export class LoginComponent implements OnInit {
submit():void{
if(this.user != null && this.password != null){
this.loginService.logging(this.user, this.password)
.pipe(
catchError((error)=>{
return of([error])
})
)
.subscribe((response)=>{
console.log('Running...', response);
.pipe()
.subscribe((response:any)=>{
console.log('Running...', response)
if(response == ""){
this.loginService.progress = false;
alert("USUARIO OU SENHA ERRADOS")
}else{
this.loginService.succeed = true
this.gotoHome()
}
});
}else{
alert('DIGITE TODOS OS CAMPOS OBRIGATÓRIOS!')
Expand Down
34 changes: 21 additions & 13 deletions frontend/main/src/app/loginservice.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,31 @@ export class LoginserviceService implements CanActivate {
constructor(private router: Router, private http: HttpClient) { }

logging(user: string, password: string) {

this.progress = true
fetch(this.TMSLoginAPI)
.then((resp) => resp.json())
.then((data) => {
let ranUsers = data.results;
return ranUsers.map((ranUser: any) => {
this.user = `${ranUser.name.first}`
this.succeed = true
new LoginComponent(this.router, this).gotoHome()
})
})
.catch((error) => {
console.log(error);

let build:any = {
'user':user,
'senha':password
}

this.http.post(this.TMSLoginAPI +'/login', build)
.pipe(
catchError((error)=>{
this.progress = false
return error
})
)
.subscribe((response:any)=>{
this.http.get(this.TMSLoginAPI+'/user/'+response[0].pessoa_id)
.subscribe((resp:any) =>{
console.log(resp);
this.user = resp.nome
})
return response
})

return this.http.get<any>(this.TMSLoginAPI + '/' + user + '/' + password)
return this.http.post(this.TMSLoginAPI +'/login', build)
}

registering(name:string ,user: string, password: string, email: string) {
Expand Down