From 87bc63e64842a2ac2dcf068421e4c8620430a3f1 Mon Sep 17 00:00:00 2001 From: ntr Date: Tue, 12 Nov 2019 15:20:02 +1100 Subject: [PATCH] password changes, account name restrictions --- WORKLOG.md | 9 ++- client/assets/rotate.svg | 96 ++++++++++++++++-------- client/assets/styles/menu.less | 4 + client/src/components/stripe.buttons.jsx | 29 ++++--- server/src/account.rs | 17 +++-- server/src/http.rs | 5 +- 6 files changed, 106 insertions(+), 54 deletions(-) diff --git a/WORKLOG.md b/WORKLOG.md index 57b663fc..c6a5bf4f 100644 --- a/WORKLOG.md +++ b/WORKLOG.md @@ -6,10 +6,13 @@ * can't reset password without knowing password =\ * ws gzip encoding -* mobile info page +* Graphics + * Img + * Skill Icons + * Buttons / General UI Theming + * Front Page ## SOON - * supporter gold name in instance (anyone whos put any money into game) * change cooldowns to delay & recharge @@ -59,7 +62,7 @@ * Items * instead of red noise, red and black bar gradient * eth adapter - *sets* + *sets* * illusions * vaporwave * crop circles diff --git a/client/assets/rotate.svg b/client/assets/rotate.svg index b48ee399..38c05927 100644 --- a/client/assets/rotate.svg +++ b/client/assets/rotate.svg @@ -2457,9 +2457,9 @@ borderopacity="1.0" inkscape:pageopacity="1" inkscape:pageshadow="2" - inkscape:zoom="0.53357639" - inkscape:cx="411.32817" - inkscape:cy="1018.5983" + inkscape:zoom="0.53546627" + inkscape:cx="561.25984" + inkscape:cy="793.70079" inkscape:document-units="mm" inkscape:current-layer="layer1" showgrid="true" @@ -2538,17 +2538,10 @@ id="layer1" transform="translate(-472.60042,755.1467)" style="display:inline"> - + transform="translate(0,2.7646743)"> + id="g5142" + transform="translate(0,-47.235375)"> + + + + + - - + id="path5003" + d="m 697.60042,-460.14669 -25,25.00001 -25,-25.00001 25,25.00001 v -75.00001 h -25" + style="opacity:1;vector-effect:none;fill:none;fill-opacity:1;stroke:#f5f5f5;stroke-width:2.9685142;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" /> + + + + + + + + - diff --git a/client/assets/styles/menu.less b/client/assets/styles/menu.less index c6349146..1ce06f73 100644 --- a/client/assets/styles/menu.less +++ b/client/assets/styles/menu.less @@ -122,6 +122,10 @@ section { // height: 3em; } + &.sub { + grid-template-columns: 1fr; + } + &.play { grid-template-columns: repeat(2, 1fr); align-items: flex-start; diff --git a/client/src/components/stripe.buttons.jsx b/client/src/components/stripe.buttons.jsx index 03d3e6b3..c23c2dfc 100644 --- a/client/src/components/stripe.buttons.jsx +++ b/client/src/components/stripe.buttons.jsx @@ -44,21 +44,26 @@ function BitsBtn(args) { } const subscription = account.subscribed - ? - : ; + ?
+
Thank you for your support
+ +
+ :
+
ยค150 / month + Chat Wheel + more
+ +
; return (
-
+
{subscription}
diff --git a/server/src/account.rs b/server/src/account.rs index 90d3f431..66af0821 100644 --- a/server/src/account.rs +++ b/server/src/account.rs @@ -22,6 +22,7 @@ use failure::Error; use failure::{err_msg, format_err}; static PASSWORD_MIN_LEN: usize = 3; +static PASSWORD_ROUNDS: u32 = 10; #[derive(Debug,Clone,Serialize,Deserialize)] pub struct Account { @@ -70,11 +71,11 @@ pub fn chat_wheel(_db: &Db, _id: Uuid) -> Result, Error> { return Ok(vec![ "gg".to_string(), "glhf".to_string(), - "hmm".to_string(), - "ok".to_string(), + "ez".to_string(), "rekt".to_string(), - "thx".to_string(), "nice".to_string(), + "wp".to_string(), + "ok".to_string(), "...".to_string(), ]) } @@ -226,8 +227,7 @@ pub fn set_password(tx: &mut Transaction, id: Uuid, current: &String, password: return Err(MnmlHttpError::BadRequest); } - let rounds = 8; - let password = hash(&password, rounds)?; + let password = hash(&password, PASSWORD_ROUNDS)?; let query = " UPDATE accounts @@ -327,10 +327,13 @@ pub fn create(name: &String, password: &String, tx: &mut Transaction) -> Result< return Err(MnmlHttpError::AccountNameNotProvided); } + if name.len() > 20 { + return Err(MnmlHttpError::AccountNameUnacceptable); + } + let id = Uuid::new_v4(); let img = Uuid::new_v4(); - let rounds = 12; - let password = hash(&password, rounds)?; + let password = hash(&password, PASSWORD_ROUNDS)?; let mut rng = thread_rng(); let token: String = iter::repeat(()) diff --git a/server/src/http.rs b/server/src/http.rs index 068234f3..2bd7d988 100644 --- a/server/src/http.rs +++ b/server/src/http.rs @@ -44,7 +44,9 @@ pub enum MnmlHttpError { AccountNameNotProvided, #[fail(display="account name unavailable")] AccountNameUnavailable, - #[fail(display="account not found")] + #[fail(display="account name unavailable")] + AccountNameUnacceptable, + #[fail(display="account name is unacceptable. 20 char max")] AccountNotFound, #[fail(display="password does not match")] PasswordNotMatch, @@ -122,6 +124,7 @@ impl From for IronError { MnmlHttpError::AccountNameNotProvided | MnmlHttpError::AccountNameUnavailable | + MnmlHttpError::AccountNameUnacceptable | MnmlHttpError::AccountNotFound | MnmlHttpError::BadRequest | MnmlHttpError::PasswordUnacceptable => (m_err.compat(), status::BadRequest),