Skip to content

Commit aa76c0c

Browse files
authored
Merge branch 'develop' into r/workspace/authenticator
Signed-off-by: Luan <63563893+ReddixT@users.noreply.github.com>
2 parents cce3d04 + 541ace7 commit aa76c0c

File tree

9 files changed

+335
-177
lines changed

9 files changed

+335
-177
lines changed

lumium-api/src/controllers/auth.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ export const signUp = async (req: express.Request<UserAuthDTO>, res: express.Res
5151
if (exists) {
5252
return res.status(500).contentType("application/json").send({ status: "EMAIL_ALREADY_EXISTS", reason: "email already exists" });
5353
}
54+
exists = await dataSource.getRepository(User).count({ where: { nickName: req.body.nickName?.toLowerCase() } }) != 0;
55+
if (exists) {
56+
return res.status(500).contentType("application/json").send({ status: "USERNAME_ALREADY_EXISTS", reason: "username is already taken" });
57+
}
5458
let salt = crypto.randomBytes(64);
5559
const derivedKey = crypto.pbkdf2Sync(
5660
Buffer.from(req.body.password, 'utf8'),

lumium-space/pages/[workspaceId]/index.tsx

Lines changed: 281 additions & 26 deletions
Large diffs are not rendered by default.

lumium-space/pages/auth/signin.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import React, { useState } from 'react'
1616
import { useApi } from '@hooks/api';
1717
import Router from 'next/router';
18-
import { AUTH_PASSWORD_RESET, AUTH_SIGNIN, AUTH_SIGNUP, ROOT, SPACES_NEW } from '@routes/space';
18+
import { AUTH_PASSWORD_RESET, AUTH_SIGNIN, AUTH_SIGNUP, ROOT, SPACES_OVERVIEW } from '@routes/space';
1919
import { useUserInfo } from '@hooks/api';
2020
import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons';
2121
import { AuthBox } from '@components/auth/AuthBox';
@@ -40,7 +40,7 @@ const SignIn: React.FC = () => {
4040
if (info?.recentWorkspace?.id) {
4141
Router.push(ROOT + info?.recentWorkspace?.id);
4242
} else {
43-
Router.push(SPACES_NEW);
43+
Router.push(SPACES_OVERVIEW);
4444
};
4545
});
4646
}

lumium-space/pages/auth/signup.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import React, { useState } from 'react';
1717
import { useApi } from "@hooks/api";
1818
import Router from 'next/router';
1919
import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons';
20-
import { AUTH_SIGNIN, AUTH_SIGNUP, SPACES_NEW } from '@routes/space';
20+
import { AUTH_SIGNIN, AUTH_SIGNUP, SPACES_OVERVIEW } from '@routes/space';
2121
import { AuthBox } from '@components/auth/AuthBox';
2222
import { useFormik } from 'formik';
2323
import { ReasonDTO } from '@types';
@@ -37,7 +37,7 @@ const SignUp: React.FC = () => {
3737
nickName: nickName
3838
}).then((res) => {
3939
if (res.status == 200) {
40-
Router.push(SPACES_NEW);
40+
Router.push(SPACES_OVERVIEW);
4141
}
4242
}, (err) => setError(err.response.data));
4343
};

lumium-space/pages/spaces/[[...path]].tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useApi, useUserInfo } from "@hooks/api";
22
import { SECURE_PONG } from "@routes/api/v1";
3-
import { AUTH_SIGNIN, ROOT, SPACES_NEW } from "@routes/space";
3+
import { AUTH_SIGNIN, ROOT, SPACES_OVERVIEW } from "@routes/space";
44
import Router from "next/router";
55
import { useEffect } from "react";
66

@@ -15,14 +15,14 @@ const Spaces: React.FC = () => {
1515
if (info?.recentWorkspace) {
1616
Router.push(ROOT + info?.recentWorkspace.id);
1717
} else {
18-
Router.push(SPACES_NEW);
18+
Router.push(SPACES_OVERVIEW);
1919
};
2020
});
2121
} else {
2222
Router.push(AUTH_SIGNIN);
2323
}
2424
});
25-
}, []);
25+
}, [api, refetchUserInfo]);
2626

2727
return null;
2828
}

lumium-space/pages/spaces/create.tsx

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useRef, useState } from 'react';
1+
import React, { useState } from 'react';
22
import {
33
Progress,
44
ButtonGroup,
@@ -17,13 +17,16 @@ import { Authenticator } from '@components/security/Authenticator';
1717
import { ViewIcon, ViewOffIcon } from '@chakra-ui/icons';
1818
import { create_workspace } from 'lumium-renderer';
1919
import { useFormik } from 'formik';
20+
import { SPACES } from '@routes/space';
21+
import Router from 'next/router';
2022

2123
const MultistepForm: React.FC = () => {
2224
const [showPassword, setShowPassword] = useState(false);
2325
const [downloadedKeys, setDownloadedKeys] = useState(false);
2426
const [credentialsMatchError, setCredentialsMatchError] = useState(false);
2527
const [step, setStep] = useState(1);
2628
const [progress, setProgress] = useState(50);
29+
2730
const nextStep = () => {
2831
if (formik.values.password == formik.values.passwordConfirm) {
2932
setStep(step + 1);
@@ -36,15 +39,20 @@ const MultistepForm: React.FC = () => {
3639
setCredentialsMatchError(true);
3740
}
3841
};
42+
3943
const handleEnter = (event) => {
4044
if (event.key == "Enter") {
4145
nextStep();
4246
};
4347
};
48+
4449
const handleDownloadKeys = () => {
45-
create_workspace(formik.values.password, formik.values.name);
46-
setDownloadedKeys(true);
50+
create_workspace(formik.values.password, formik.values.name).then(() => {
51+
setDownloadedKeys(true);
52+
Router.push(SPACES);
53+
});
4754
};
55+
4856
const formik = useFormik({
4957
initialValues: {
5058
name: "",
@@ -56,6 +64,7 @@ const MultistepForm: React.FC = () => {
5664
},
5765
validateOnChange: (false),
5866
});
67+
5968
return (
6069
<Authenticator>
6170
<Flex
@@ -79,11 +88,11 @@ const MultistepForm: React.FC = () => {
7988
step === 1 && (
8089
<>
8190
<Heading w="100%" textAlign={'center'} fontWeight="normal" mb="2%">
82-
Space Creation
91+
Create a new workspace
8392
</Heading>
8493
<FormControl isRequired>
8594
<FormLabel fontWeight={'normal'}>
86-
Your Space Name
95+
Workspace Name
8796
</FormLabel>
8897
<Input
8998
name={"name"}
@@ -93,8 +102,8 @@ const MultistepForm: React.FC = () => {
93102
data-cy={"nameInput"}
94103
/>
95104
</FormControl>
96-
<FormControl isRequired>
97-
<FormLabel>Password</FormLabel>
105+
<FormControl isRequired mt="5">
106+
<FormLabel>Master Workspace Password</FormLabel>
98107
<InputGroup>
99108
<Input
100109
name={"password"}
@@ -115,7 +124,7 @@ const MultistepForm: React.FC = () => {
115124
</InputRightElement>
116125
</InputGroup>
117126
</FormControl>
118-
<FormControl isRequired isInvalid={credentialsMatchError}>
127+
<FormControl isRequired isInvalid={credentialsMatchError} mt="5" >
119128
<FormLabel>Repeat Password</FormLabel>
120129
<Input
121130
name={"passwordConfirm"}
@@ -134,15 +143,30 @@ const MultistepForm: React.FC = () => {
134143
<Heading w="100%" textAlign={'center'} fontWeight="normal" mb="2%">
135144
Download Recovery Keys
136145
</Heading>
137-
<Text w="100%" textAlign={'center'}>
146+
<Heading textAlign={'center'}>
147+
DISCLAIMER
148+
</Heading>
149+
<Text w="100%" mt={"5"}>
138150
Download your recovery keys and secure them in a safe location. These will be needed in case you forget your password.
139151
</Text>
140-
<Flex w="100%" justifyContent="center">
141-
<Button backgroundColor={"lightgreen"} onClick={handleDownloadKeys} data-cy={"downloadButton"}>Download Keys and Create Space</Button>
152+
<Text w="100%" mt={"5"}>
153+
If you do not have access to your password or your recovery codes, you will not be able to decrypt the content in your workspace. We at lumium will not be able to help you recover your data.
154+
</Text>
155+
<Text w="100%" mt={"5"}>
156+
As your data is fully end-to-end encrypted, key management is your sole responsibility. You will be able to generate additional codes and invalidate existing codes later on.
157+
</Text>
158+
<Text w="100%" mt={"5"}>
159+
As soon as you click the button below, your workspace will be created and you will be prompted to download your recovery keys. The downloaded file will be named `lumium_recovery_keys.txt` and will contain one key per line.
160+
</Text>
161+
<Text w="100%" mt={"5"}>
162+
lumium cannot read your workspace content, except for some metadata (information like which users have access to which workspace, your workspace title, which page was created by which user, when was the last time a user has logged in etc.). We cannot read data like the titles/content of pages in your workspace.
163+
</Text>
164+
<Flex w="100%" mt={"5"} justifyContent="center">
165+
<Button backgroundColor={"darkgreen"} onClick={handleDownloadKeys} data-cy={"downloadButton"}>I have read the above disclaimer and understand my own responsibility</Button>
142166
</Flex>
143167
</>
144168
)}
145-
<ButtonGroup w="100%" mt="auto">
169+
<ButtonGroup w="100%" mt="5">
146170
<Flex w="100%" justifyContent="space-between">
147171
<Flex>
148172
<Button
@@ -159,6 +183,7 @@ const MultistepForm: React.FC = () => {
159183
>
160184
Back
161185
</Button>
186+
{step!=2 &&
162187
<Button
163188
w="7rem"
164189
type="submit"
@@ -167,19 +192,8 @@ const MultistepForm: React.FC = () => {
167192
>
168193
Next
169194
</Button>
195+
}
170196
</Flex>
171-
{
172-
downloadedKeys && (
173-
<Button
174-
w="7rem"
175-
colorScheme="red"
176-
variant="solid"
177-
data-cy={"submitButton"}
178-
>
179-
Submit
180-
</Button>
181-
)
182-
}
183197
</Flex>
184198
</ButtonGroup>
185199
</form>

lumium-space/pages/spaces/join.tsx

Lines changed: 0 additions & 80 deletions
This file was deleted.

lumium-space/pages/spaces/new.tsx renamed to lumium-space/pages/spaces/overview.tsx

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
Flex,
55
} from '@chakra-ui/react';
66
import Router from 'next/router';
7-
import { SPACES_CREATE, SPACES_JOIN } from '@routes/space';
7+
import { SPACES_CREATE } from '@routes/space';
88
import { Authenticator } from '@components/security/Authenticator';
99

1010
const CreateOrJoin: React.FC = () => {
@@ -21,10 +21,10 @@ const CreateOrJoin: React.FC = () => {
2121
padding={"4%"}
2222
>
2323
<Text fontSize={'6xl'} fontWeight={800}>
24-
Create Space
24+
Create workspace
2525
</Text>
2626
<Text fontSize={'2xl'}>
27-
Create your own space now and add collaborators.
27+
Create your own workspace now and add collaborators.
2828
</Text>
2929
<Button
3030
mt="auto"
@@ -46,43 +46,9 @@ const CreateOrJoin: React.FC = () => {
4646
Start now
4747
</Button>
4848
</Flex>
49-
<Flex
50-
m={"5%"}
51-
w={'30%'}
52-
boxShadow={'2xl'}
53-
rounded={'md'}
54-
overflow={'hidden'}
55-
flexDir="column"
56-
padding={"4%"}
57-
>
58-
<Text fontSize={'6xl'} fontWeight={800}>
59-
Join Space
60-
</Text>
61-
<Text fontSize={'2xl'}>
62-
Join an existing collaborative Space with Spacekey and Spacepassword.
63-
</Text>
64-
<Button
65-
mt="auto"
66-
w={'full'}
67-
bg={'green.400'}
68-
color={'white'}
69-
rounded={'xl'}
70-
boxShadow={'0 5px 20px 0px rgb(72 187 120 / 43%)'}
71-
_hover={{
72-
bg: 'green.500',
73-
}}
74-
_focus={{
75-
bg: 'green.500',
76-
}}
77-
data-cy={"joinButton"}
78-
onClick={() => Router.push(SPACES_JOIN)}
79-
>
80-
Start now
81-
</Button>
82-
</Flex>
8349
</Flex>
8450
</Authenticator>
8551
);
8652
};
8753

88-
export default CreateOrJoin;
54+
export default CreateOrJoin;

routes/space/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ export const AUTH_SIGNIN = AUTH + '/signin';
55
export const AUTH_SIGNUP = AUTH + '/signup';
66
export const AUTH_PASSWORD_RESET = AUTH + '/reset-password';
77
export const SPACES = ROOT + 'spaces';
8-
export const SPACES_NEW = SPACES + '/new';
8+
export const SPACES_OVERVIEW = SPACES + '/overview';
99
export const SPACES_CREATE = SPACES + '/create';
10-
export const SPACES_JOIN = SPACES + '/join';
1110
export const WORKSPACE = ROOT + 'workspace';
1211

1312
export const AUTH_USER = AUTH + '/user';

0 commit comments

Comments
 (0)