Skip to content

Commit 0138c04

Browse files
committed
[Major] Allows Instant usage without approval
1 parent 9fc1554 commit 0138c04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+985
-208
lines changed

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@
2323
"cookie-parser": "1.4.3",
2424
"cookie-storage": "^2.0.2",
2525
"cors": "^2.7.1",
26+
"csurf": "^1.9.0",
2627
"dauria": "^1.1.4",
2728
"dotenv-safe": "^4.0.2",
29+
"express-locale": "^1.0.1",
2830
"feathers": "^2.0.1",
2931
"feathers-authentication": "^1.0.2",
3032
"feathers-authentication-client": "^0.1.6",
@@ -40,6 +42,7 @@
4042
"feathers-mongoose": "^3.5.1",
4143
"feathers-permissions": "git+https://github.com/feathersjs/feathers-permissions.git#filters",
4244
"feathers-reduxify-services": "^0.3.0",
45+
"feathers-rest": "^1.6.0",
4346
"feathers-socketio": "^1.4.1",
4447
"feathers-sync": "^0.1.1",
4548
"fs-blob-store": "^5.2.1",
@@ -58,6 +61,7 @@
5861
"multer": "^1.2.0",
5962
"passport": "0.3.2",
6063
"passport-facebook": "^2.1.1",
64+
"passport-google": "^0.3.0",
6165
"passport-google-oauth": "^1.0.0",
6266
"passport-twitter": "^1.0.4",
6367
"pmx": "^0.6.4",

src/actions/runtime.js

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ export const setRuntimeVariable = (name, value) => ({
22
type: "SET_RUNTIME_VARIABLE",
33
payload: {name, value}
44
})
5+
6+
export const toggleLocale = () => ({
7+
type: "TOGGLE_LOCALE"
8+
})

src/actions/search.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ export const search = (value, service, options = {}) => (dispatch, getState) =>
3939
}
4040
}
4141

42-
export const sort = service => dispatch => {
42+
export const sort = (service, options) => dispatch => {
4343
dispatch(toggleSort(service))
44-
dispatch(search(false, service))
44+
dispatch(search(false, service, options))
4545
}
4646

4747
export const filter = (value, service) => dispatch => {
4848
dispatch(setFilter(value, service))
49-
dispatch(search(false, service))
49+
dispatch(search(false, service, options))
5050
}

src/actions/user.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const authenticate = (email, password, msg = "ยินดีต้อน
4242
export const register = (username, email, password) => (dispatch) => {
4343
app.service("accounts").create({username, email, password}).then(user => {
4444
if (user) {
45-
dispatch(authenticate(email, password, "ยินดีต้อนรับสู่ FlipED ครับ! กรุณายืนยันตัวตนกับผู้ดูแลระบบก่อนครับ"))
45+
dispatch(authenticate(email, password, "ยินดีต้อนรับสู่ FlipED ครับ! ท่านสามารถสร้างห้องเรียนได้ทันที"))
4646
dispatch(reset("signup"))
4747
console.info("Registration Success", user)
4848
}
@@ -68,6 +68,22 @@ export const join = (code, username, email, password) => dispatch => {
6868
})
6969
}
7070

71+
export const joinExisting = code => dispatch => {
72+
app.service("invitation").get(code)
73+
.then(({status, message}) => {
74+
if (status === "JOIN_EXISTING_SUCCESS") {
75+
dispatch(push("/courses"))
76+
dispatch(reset("joinExisting"))
77+
dispatch(setSnackbar(message))
78+
console.info("Join with existing account success")
79+
}
80+
})
81+
.catch(err => {
82+
console.error("JOIN_EXISTING_ERROR", err)
83+
dispatch(setSnackbar("พบปัญหา"))
84+
})
85+
}
86+
7187
export const logout = () => dispatch => {
7288
dispatch(services.socket.get("offline"))
7389
app.logout().then(() => {

src/client/api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ app.configure(authentication(IS_CLIENT ? {
2828
} : {}))
2929

3030
const servicesList = [
31-
"debug", "users", "classes", "lessons", "messages", "comments", "quizzes",
32-
"assignments", "track", "socket", "upload", "accounts", "userstate"
31+
"authManagement", "users", "classes", "lessons", "messages", "comments", "quizzes",
32+
"assignments", "track", "socket", "upload", "accounts", "userstate", "students"
3333
]
3434

3535
export const services = reduxifyServices(app, servicesList)

src/components/Guest.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,20 @@ const Guest = (({user}) => (
3939
<div>
4040
<h2 style={h2}>
4141
{user.roles === "guest" ?
42-
"ยังไม่ได้รับการยืนยันบุคคล" : "ท่านมีสิทธิในการเข้าถึงไม่เพียงพอ"}
42+
"ท่านถูกระงับสิทธิในการใช้งาน" : "ท่านมีสิทธิในการเข้าถึงไม่เพียงพอ"}
4343
</h2>
4444
<p style={p}>
4545
{user.roles === "guest" ? (
4646
<span>
47-
ในขณะนี้ คุณ <b>{user.username}</b> ยังไม่ได้รับการยืนยันบุคคล <br />
48-
รบกวนคุณ {user.username} <b>ยืนยันตัวตนกับผู้ดูแลระบบ</b>ด้วยครับ
47+
เนื่องจากคุณ {user.username} ถูกระงับสิทธิในการใช้งานชั่วคราว รบกวนคุณ <b>{user.username}</b>
48+
<Link to="/landing#contact" style={{textDecoration: "none"}}>
49+
&nbsp;ติดต่อกับผู้ดูแลระบบ&nbsp;
50+
</Link>ด้วยครับ
4951
</span>
5052
) : (
5153
<span>
5254
คุณ <b>{user.username}</b>
53-
ซึ่งมีสิทธิเป็น <b>{ROLE[user.roles || "guest"].th}</b>
55+
ซึ่งมีสิทธิเป็น <b>{ROLE[user.roles || "guest"].th} </b>
5456
มีสิทธิไม่เพียงพอที่จะเข้าถึงส่วนนี้ครับ
5557
</span>
5658
)}

src/components/Html.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ const Html = ({
2828

2929
<meta charSet="utf-8" />
3030
<meta httpEquiv="Content-Type" content="text/html;charset=UTF-8" />
31-
<meta httpEquiv="x-ua-compatible" content="ie=edge" />
32-
<meta name="viewport" content="width=device-width, initial-scale=1" />
31+
<meta httpEquiv="x-ua-compatible" content="IE=edge" />
32+
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
3333
<meta name="description" content={description} />
3434
<meta name="keywords" content={KEYWORDS} />
3535
<meta name="author" content={AUTHOR} />
3636
<meta name="copyright" content={COPYRIGHT} />
3737
<meta name="application-name" content={APP_NAME} />
3838

39+
<link rel="canonical" href="https://fliped.xyz" />
3940
<link rel="manifest" href="/manifest.json" />
4041
<link rel="icon" href="/images/touch/favicon.ico" />
4142
<link rel="shortcut icon" href="/images/touch/favicon-96x96.png" />
@@ -48,6 +49,7 @@ const Html = ({
4849
<meta name="apple-mobile-web-app-title" content="FlipED" />
4950

5051
<meta property="og:title" content={title} />
52+
<meta property="og:site_name" content={APP_NAME} />
5153
<meta property="og:type" content="website" />
5254
<meta property="og:image" content={IMAGE} />
5355
<meta property="og:url" content={URL} />

src/components/Layout/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const Layout = props => (
1616
<Sidebar />
1717
<div className={s.view}>
1818
<Navbar />
19-
<div className={s.main}>
19+
<div className={!props.noTop && s.main}>
2020
{props.children}
2121
</div>
2222
</div>
+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from "react"
2+
import {connect} from "react-redux"
3+
import {Link} from "react-router"
4+
import {Field, reduxForm} from "redux-form"
5+
import withStyles from "isomorphic-style-loader/lib/withStyles"
6+
import Tooltip from "react-tooltip"
7+
8+
import Button from "../Button"
9+
10+
import {joinExisting} from "../../actions/user"
11+
12+
import s from "./Login.scss"
13+
14+
const JoinForm = reduxForm({form: "joinExisting"})(withStyles(s)(props => (
15+
<form className={s.form} method="post" onSubmit={props.handleSubmit}>
16+
<Tooltip place="top" type="dark" effect="float" />
17+
<div className={s.card}>
18+
<input
19+
data-tip="ชื่อผู้ใช้"
20+
style={{width: "100%", color: "darkgrey"}}
21+
className={s.field}
22+
type="text"
23+
value={`ชื่อผู้ใช้: ${props.user.username}`}
24+
disabled
25+
/>
26+
{props.code ? (
27+
<input
28+
data-tip="รหัสห้องเรียน"
29+
style={{width: "100%", color: "darkgrey"}}
30+
className={s.field}
31+
type="text"
32+
value={`รหัสเข้าห้องเรียนถูกป้อนโดยอัตโนมัติ: ${props.code}`}
33+
disabled
34+
/>
35+
) : (
36+
<Field
37+
name="code"
38+
data-tip="คัดลอกรหัส 24 หลักที่ท่านได้รับจากผู้สอน"
39+
placeholder="รหัสเข้าห้องเรียน"
40+
style={{width: "100%"}}
41+
component="input"
42+
className={s.field}
43+
type="text"
44+
autoFocus
45+
/>
46+
)}
47+
</div>
48+
<Button className={s.login} type="submit" light>
49+
เข้าร่วมห้องเรียน
50+
</Button>
51+
<p className={s.message}>
52+
ท่านสามารถเข้าร่วมห้องเรียนใหม่โดยใช้บัญชีนี้ได้ทันที
53+
</p>
54+
</form>
55+
)))
56+
57+
const ConnectedJoinForm = props => (
58+
<JoinForm onSubmit={props.handleJoin} code={props.code} user={props.user} />
59+
)
60+
61+
const mapStateToProps = state => ({
62+
user: state.user || {}
63+
})
64+
65+
const mapDispatchToProps = (dispatch, props) => ({
66+
handleJoin: ({code = props.code}) => {
67+
dispatch(joinExisting(code))
68+
}
69+
})
70+
71+
export default connect(mapStateToProps, mapDispatchToProps)(ConnectedJoinForm)

src/components/Login/JoinForm.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const JoinForm = reduxForm({form: "join"})(withStyles(s)(props => (
5656
component="input"
5757
className={s.field}
5858
type="email"
59+
pattern=".+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
5960
required
6061
/>
6162
<Field
@@ -85,7 +86,7 @@ const JoinForm = reduxForm({form: "join"})(withStyles(s)(props => (
8586
เข้าร่วมห้องเรียน
8687
</Button>
8788
<p className={s.message}>
88-
มีบัญชีผู้ใช้อยู่แล้ว? <Link to="/login">ใช้บัญชีเดิม</Link>
89+
มีบัญชีผู้ใช้อยู่แล้ว? <Link to="/login">ลงชื่อเข้าใช้บัญชีเดิม</Link>และเข้ามายังลิงก์นี้อีกครั้ง
8990
</p>
9091
</form>
9192
)))

src/components/Login/Signup.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const SignupForm = reduxForm({form: "signup"})(withStyles(s)(props => (
3535
component="input"
3636
className={s.field}
3737
type="email"
38+
pattern=".+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
3839
required
3940
/>
4041
<Field
@@ -61,7 +62,7 @@ const SignupForm = reduxForm({form: "signup"})(withStyles(s)(props => (
6162
/>
6263
</div>
6364
<Button className={s.login} type="submit" light>
64-
สมัครสมาชิก
65+
สร้างห้องเรียน
6566
</Button>
6667
<p className={s.message}>
6768
สมัครสมาชิกแล้ว? <Link to="/login">เข้าสู่ระบบ</Link>

src/components/Login/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const LoginForm = reduxForm({form: "login"})(withStyles(s)(props => (
2020
component="input"
2121
className={s.field}
2222
type="email"
23+
pattern=".+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
2324
required
2425
autoFocus
2526
/>

src/components/Navbar/Navbar.scss

-6
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,3 @@
8585
fill: $white;
8686
}
8787
}
88-
89-
@media screen and (max-width: $screen-sm-min) {
90-
.root {
91-
position: fixed;
92-
}
93-
}

src/components/Sidebar/Sidebar.scss

+45-5
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,21 @@ $sidebarWidth: 6.6em;
77
color: $grey;
88
}
99

10+
.sidebarWrapper {
11+
flex: 0;
12+
background: #fefefe;
13+
14+
height: auto;
15+
min-height: 100%;
16+
box-shadow: $zFlow;
17+
18+
z-index: 1;
19+
}
20+
1021
.sidebar {
1122
background: #fefefe;
1223
color: $grey;
13-
box-shadow: $zFlow;
1424

15-
flex: 0;
1625
min-width: $sidebarWidth;
1726
max-width: $sidebarWidth;
1827
height: auto;
@@ -22,15 +31,43 @@ $sidebarWidth: 6.6em;
2231
font-weight: 400;
2332
text-align: center;
2433

25-
z-index: 1;
34+
padding-top: 2.5em;
35+
}
36+
37+
.sidebarContainer {
38+
position: fixed;
39+
min-width: $sidebarWidth;
40+
max-width: $sidebarWidth;
41+
}
42+
43+
.bottomMobile {
44+
display: none;
45+
}
46+
47+
.sidebarMobile {
48+
display: none;
2649
}
2750

2851
@media screen and (max-width: $screen-sm-min) {
29-
.sidebar:not(.sidebarMobile) {
52+
.bottomMobile {
53+
display: block;
54+
position: fixed;
55+
bottom: 0;
56+
left: 0;
57+
width: 100%;
58+
z-index: 1;
59+
}
60+
61+
.sidebar {
3062
display: none;
3163
}
3264

33-
.sidebarMobile {
65+
.sidebarContainer {
66+
min-width: 100%;
67+
max-width: 100%;
68+
}
69+
70+
.sidebarMobile.show {
3471
position: fixed;
3572
display: flex;
3673
flex-direction: column;
@@ -42,6 +79,9 @@ $sidebarWidth: 6.6em;
4279
right: 0;
4380
bottom: 0;
4481
min-width: 100%;
82+
83+
background: white;
84+
min-height: 100%;
4585
}
4686

4787
.logo > img {

0 commit comments

Comments
 (0)