Skip to content

Commit

Permalink
Corrigido login/cadastro
Browse files Browse the repository at this point in the history
  • Loading branch information
leonp967 committed May 2, 2019
1 parent ca3cbaa commit ac4a97d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
5 changes: 3 additions & 2 deletions backend/controllers/user_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ exports.createUser = (email, password, cpf, nome) => {
if(error) {
return console.dir(error);
}
importToWallet(body.certificate, body.key, email);
const bodyJson = JSON.parse(body);
importToWallet(bodyJson.certificate, bodyJson.key, email);
ipcRenderer.send('signup-finish', response.statusCode);
});
}
Expand All @@ -57,7 +58,7 @@ exports.userLogin = (email, password) => {
if(error) {
return console.dir(error);
}
if(response.statusCode == 201){
if(response.statusCode == 200){
userEmail = body.email;
userName = body.name;
userCpf = body.cpf;
Expand Down
22 changes: 18 additions & 4 deletions backend/prontuchain-connection/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: mychannel.firstnetwork.connectionprofile
x-type: "hlfv1"
description: "BankPeerContract methods will be used through this profile"
description: ""
version: "1.0"

channels:
Expand Down Expand Up @@ -36,7 +36,7 @@ organizations:
- peer0.org1.example.com
- peer1.org1.example.com
certificateAuthorities:
- certificate-authority-org1
- ca.example.com
adminPrivateKey:
path: ../first-network/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/5b2ceee4ea5262c74d86b01c551614a184e9b2fd753ee35b6e5772cfac70202c_sk
signedCert:
Expand All @@ -48,7 +48,7 @@ organizations:
- peer0.org2.example.com
- peer1.org2.example.com
certificateAuthorities:
- certificate-authority-org2
- ca.example.com
adminPrivateKey:
path: ../first-network/crypto-config/peerOrganizations/org2.example.com/users/[email protected]/msp/keystore/28fdb4517421272d8afc238cf753ce92e599eb55b9a5a35bf6e8c7381a836112_sk
signedCert:
Expand Down Expand Up @@ -93,4 +93,18 @@ peers:
ssl-target-name-override: peer1.org2.example.com
request-timeout: 120001
tlsCACerts:
path: ../first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem
path: ../first-network/crypto-config/peerOrganizations/org2.example.com/peers/peer1.org2.example.com/msp/tlscacerts/tlsca.org2.example.com-cert.pem

certificateAuthorities:
ca.example.com:

url: grpc://localhost:7054

httpOptions:
verify: false

registrar:
enrollId: admin
enrollSecret: adminpw

caName: ca.example.com
7 changes: 5 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,11 @@ function main () {
event.sender.send('signup-check', response);
})

ipcMain.on('login-finish', (event, response) => {
mainWindow.loadFile(path.join('renderer', 'patient-home.html'));
ipcMain.on('login-finish', (event, code) => {
if(code == 200)
mainWindow.loadFile(path.join(__dirname, '/renderer/patient-home.html'));
else
mainWindow.send('login-failed');
})

// add-todo from add todo window
Expand Down
14 changes: 13 additions & 1 deletion renderer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

const { ipcRenderer } = require('electron');
const UserController = require('../backend/controllers/user_controller');
const dialog = require('electron').remote.dialog

// delete todo by its text value ( used below in event listener)
const deleteTodo = (e) => {
ipcRenderer.send('delete-todo', e.target.textContent)
};

document.getElementById('login-button').addEventListener('click', () => {
document.getElementById('login-button').addEventListener('click', async(evt) => {
evt.preventDefault();
const form = document.getElementById('loginForm');
const email = form[0].value;
const senha = form[1].value;
Expand All @@ -19,6 +21,16 @@ document.getElementById('signup-button').addEventListener('click', () => {
ipcRenderer.send('signup');
});

ipcRenderer.on('login-failed', () => {
const options = {
type: 'error',
buttons: ['OK'],
title: 'Erro',
message: 'Email ou senha inválidos!'
};
dialog.showMessageBox(null, options);
});

// on receive todos
//ipcRenderer.on('todos', (event, todos) => {
// // get the todoList ul
Expand Down

0 comments on commit ac4a97d

Please sign in to comment.