Skip to content

Commit 173665b

Browse files
committed
New user signup, still need to set pw as required
Co-authored-by: Jon Cruz [email protected] Co-authored-by: Elena Atencio [email protected] Co-authored-by: John Donato [email protected]
1 parent 9ad9905 commit 173665b

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

app/components/SignUp.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ const SignUp:React.FC = React.memo(() => {
2828
}
2929

3030
ipcRenderer.invoke('addUser', { username, email, password})
31-
.then(validSignUp => {
32-
if (validSignUp) {
33-
setUser(username);
34-
navigate('/');
35-
} else
36-
setFailedSignUp(<p>Sorry, your sign up failed. Please try a different username or email</p>);
37-
}).catch(error => {
31+
.then((message) => {
32+
if (message === true) {
33+
setUser(username);
34+
console.log(username)
35+
navigate('/');
36+
} else {
37+
setFailedSignUp(<p>Sorry, your sign up failed. Please try a different username or email</p>)
38+
}
39+
}).catch(error => {
3840
console.error('Failed to sign up:', error);
3941
setFailedSignUp(<p>Sorry, your sign up failed. Please try again later</p>);
4042
});

electron/routes/dashboard.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ipcMain, IpcMainEvent } from 'electron';
1+
import { BrowserWindow, ipcMain, IpcMainEvent } from 'electron';
22
import moment from 'moment';
33
import path from 'path';
44
import fs from 'fs';
@@ -160,25 +160,28 @@ ipcMain.on('changeMode', (message: IpcMainEvent, currMode: string) => {
160160
message.returnValue = currMode;
161161
});
162162

163-
ipcMain.on(
163+
ipcMain.handle(
164164
'addUser',
165165
(message: IpcMainEvent, user: { username: string; password: string; email: string }) => {
166166
const { username, password, email } = user;
167+
console.log(user)
167168

168169
// Verify that username and email have not been taken
169170
const settings = JSON.parse(fs.readFileSync(settingsLocation).toString('utf8'));
170-
if (username in settings) {
171+
if (settings[username]) {
171172
message.returnValue = false;
172-
return;
173+
return message.returnValue;
173174
}
174-
175+
175176
// Add the new user to the local storage
176-
const newUser = new User(username, password, email);
177-
settings[username] = newUser;
178-
fs.writeFileSync(settingsLocation, JSON.stringify(settings, null, '\t'));
179-
currentUser = username;
180-
message.returnValue = true;
181-
return;
177+
else {
178+
const newUser = new User(username, password, email);
179+
settings[username] = newUser;
180+
fs.writeFileSync(settingsLocation, JSON.stringify(settings, null, '\t'));
181+
currentUser = username;
182+
message.returnValue = true;
183+
return message.returnValue;
184+
}
182185
}
183186
);
184187

examples/microservices/books/BookController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ BookController.createBook = (req, res, next) => {
1313
}, (err, result) => {
1414
if (err) {
1515
console.log(`This is the error I am getting back ${err}`);
16-
return res.send(404).json(err);
16+
return res.status(404).json(err);
1717
}
1818
res.locals.createBook = result;
1919
return next();

0 commit comments

Comments
 (0)