Commit 929b2ba6 authored by Roger Jungemann's avatar Roger Jungemann
Browse files

Almost done with login changes

parent 514a6a5d
......@@ -56,9 +56,9 @@ function runApp(initial_state) {
initial_state.user.maybeLoggedIn =
store.get('autopost2') || sessionStorage.getItem('username');
if (initial_state.user.maybeLoggedIn) {
const username =
sessionStorage.getItem('username') ||
new Buffer(store.get('autopost2'), 'hex').toString().split('\t')[0];
const username = new Buffer(store.get('autopost2'), 'hex')
.toString()
.split('\t')[0];
initial_state.user.current = {
username,
};
......
......@@ -109,6 +109,39 @@ class Header extends React.Component {
page_title.charAt(0).toUpperCase() + page_title.slice(1);
}
const wallet_link = `/@${username}/transfers`;
const reset_password_link = `/@${username}/password`;
const settings_link = `/@${username}/settings`;
const pathCheck = userPath === '/submit.html' ? true : null;
const user_menu = [
{
link: wallet_link,
icon: 'wallet',
value: tt('g.wallet'),
},
{
link: '#',
icon: 'eye',
onClick: toggleNightmode,
value: tt('g.toggle_nightmode'),
},
{
link: reset_password_link,
icon: 'key',
value: tt('g.change_password'),
},
{ link: settings_link, icon: 'cog', value: tt('g.settings') },
loggedIn
? {
link: '#',
icon: 'enter',
onClick: logout,
value: tt('g.logout'),
}
: { link: '#', onClick: showLogin, value: tt('g.login') },
];
return (
<header className="Header">
<nav className="row Header__nav">
......@@ -123,6 +156,13 @@ class Header extends React.Component {
{/*NOT LOGGED IN SIGN UP LINK*/}
{!loggedIn && (
<span className="Header__user-signup show-for-medium">
<a
className="Header__login-link"
href="/login.html"
onClick={showLogin}
>
{tt('g.login')}
</a>
<a
className="Header__signup-link"
href={SIGNUP_URL}
......@@ -131,7 +171,23 @@ class Header extends React.Component {
</a>
</span>
)}
{/*USER AVATAR */}
{loggedIn && (
<DropdownMenu
className={'Header__usermenu'}
items={user_menu}
title={username}
el="span"
selected={tt('g.rewards')}
position="left"
>
<li className={'Header__userpic '}>
<span title={username}>
<Userpic account={username} />
</span>
</li>
</DropdownMenu>
)}
{/*HAMBURGER*/}
<span
onClick={showSidePanel}
......
......@@ -18,14 +18,10 @@ import { SIGNUP_URL } from 'shared/constants';
class LoginForm extends Component {
static propTypes = {
// Steemit.
login_error: PropTypes.string,
loginError: PropTypes.string,
onCancel: PropTypes.func,
};
static defaultProps = {
afterLoginRedirectToWelcome: false,
};
constructor(props) {
super();
const cryptoTestResult = runTests();
......@@ -91,15 +87,15 @@ class LoginForm extends Component {
}
SignUp() {
const onType = document.getElementsByClassName('OpAction')[0]
.textContent;
const opAction = document.getElementsByClassName('OpAction')[0];
const onType = opAction ? opAction.textContent : 'Login';
serverApiRecordEvent('FreeMoneySignUp', onType);
window.location.href = SIGNUP_URL;
}
SignIn() {
const onType = document.getElementsByClassName('OpAction')[0]
.textContent;
const opAction = document.getElementsByClassName('OpAction')[0];
const onType = opAction ? opAction.textContent : 'Login';
serverApiRecordEvent('SignIn', onType);
}
......@@ -116,6 +112,8 @@ class LoginForm extends Component {
};
render() {
const loginType = this.props.loginType;
if (!process.env.BROWSER) {
return (
<div className="row">
......@@ -168,12 +166,7 @@ class LoginForm extends Component {
);
}
const {
loginBroadcastOperation,
dispatchSubmit,
afterLoginRedirectToWelcome,
msg,
} = this.props;
const { loginBroadcastOperation, dispatchSubmit, msg } = this.props;
const { username, password, saveLogin } = this.state;
const { submitting, valid, handleSubmit } = this.state.login;
const { usernameOnChange, onCancel /*qrReader*/ } = this;
......@@ -200,7 +193,7 @@ class LoginForm extends Component {
let error =
password.touched && password.error
? password.error
: this.props.login_error;
: this.props.loginError;
if (error === 'owner_login_blocked') {
error = (
<span>
......@@ -252,7 +245,7 @@ class LoginForm extends Component {
message = (
<div className="callout primary">
<p>
{tt('loginform_jsx.password_update_succes', {
{tt('loginform_jsx.password_update_success', {
accountName: username.value,
})}
</p>
......@@ -273,27 +266,30 @@ class LoginForm extends Component {
.toLowerCase()
.indexOf('transfer') >= 0;
const titleText = !isTransfer ? (
<h3>
{tt('loginform_jsx.returning_users')}
<span className="OpAction">{title}</span>
</h3>
) : (
<h3>
<span className="OpAction">
{tt('loginform_jsx.sign_transfer')}
</span>
</h3>
);
let titleText;
if (isTransfer) {
titleText = (
<h3>
<span className="OpAction">
{tt('loginform_jsx.sign_transfer')}
</span>
</h3>
);
} else if (loginType === 'basic') {
titleText = <h3>{tt('loginform_jsx.login_to_wallet')}</h3>;
} else {
titleText = (
<h3>
{tt('loginform_jsx.returning_users')}
<span className="OpAction">{title}</span>
</h3>
);
}
const signupLink = (
<div className="sign-up">
<hr />
<p>
{tt('loginform_jsx.join_our')}{' '}
<em>{tt('loginform_jsx.amazing_community')}</em>
{tt('loginform_jsx.to_comment_and_reward_others')}
</p>
<p>{tt('loginform_jsx.dont_have_an_account')}</p>
<button
type="button"
className="button hollow"
......@@ -309,11 +305,7 @@ class LoginForm extends Component {
onSubmit={handleSubmit(({ data }) => {
// bind redux-form to react-redux
console.log('Login\tdispatchSubmit');
return dispatchSubmit(
data,
loginBroadcastOperation,
afterLoginRedirectToWelcome
);
return dispatchSubmit(data, loginBroadcastOperation);
})}
onChange={this.props.clearError}
method="post"
......@@ -341,7 +333,11 @@ class LoginForm extends Component {
type="password"
required
ref="pw"
placeholder={tt('loginform_jsx.password_or_wif')}
placeholder={
loginType === 'basic'
? tt('loginform_jsx.enter_steem_key')
: tt('loginform_jsx.password_or_wif')
}
{...password.props}
autoComplete="on"
disabled={submitting}
......@@ -447,7 +443,8 @@ import { connect } from 'react-redux';
export default connect(
// mapStateToProps
state => {
const login_error = state.user.get('login_error');
const loginType = state.user.get('login_type');
const loginError = state.user.get('login_error');
const currentUser = state.user.get('current');
const loginBroadcastOperation = state.user.get(
'loginBroadcastOperation'
......@@ -476,9 +473,10 @@ export default connect(
let msg = '';
const msg_match = window.location.hash.match(/msg\=([\w]+)/);
if (msg_match && msg_match.length > 1) msg = msg_match[1];
hasError = !!login_error;
hasError = !!loginError;
return {
login_error,
loginType,
loginError,
loginBroadcastOperation,
initialValues,
initialUsername,
......@@ -489,11 +487,7 @@ export default connect(
// mapDispatchToProps
dispatch => ({
dispatchSubmit: (
data,
loginBroadcastOperation,
afterLoginRedirectToWelcome
) => {
dispatchSubmit: (data, loginBroadcastOperation) => {
const { password, saveLogin } = data;
const username = data.username.trim().toLowerCase();
if (loginBroadcastOperation) {
......@@ -518,7 +512,6 @@ export default connect(
username,
password,
saveLogin,
afterLoginRedirectToWelcome,
operationType: type,
})
);
......@@ -530,7 +523,7 @@ export default connect(
username,
password,
saveLogin,
afterLoginRedirectToWelcome,
afterLoginRedirectToTransfers: true,
})
);
}
......
......@@ -209,12 +209,7 @@ class Settings extends React.Component {
progress,
} = this.state;
const {
account,
isOwnAccount,
user_preferences,
toggleNightmode,
} = this.props;
const { account, isOwnAccount, user_preferences } = this.props;
return (
<div className="Settings">
......@@ -223,13 +218,6 @@ class Settings extends React.Component {
onSubmit={this.handleSubmitForm}
className="small-12 medium-6 large-4 columns"
>
<button
className="toggle-nightmode button hollow"
onClick={toggleNightmode}
>
{tt('g.toggle_nightmode')}
</button>
<hr />
<h4>{tt('settings_jsx.public_profile_settings')}</h4>
{progress.message && (
<div className="info">{progress.message}</div>
......@@ -408,9 +396,5 @@ export default connect(
};
dispatch(transactionActions.broadcastOperation(options));
},
toggleNightmode: e => {
if (e) e.preventDefault();
dispatch(appActions.toggleNightmode());
},
})
)(Settings);
......@@ -15,7 +15,7 @@ class Login extends React.Component {
return (
<div className="Login row">
<div className="column">
<LoginForm afterLoginRedirectToWelcome />
<LoginForm />
</div>
</div>
);
......
/* eslint react/prop-types: 0 */
import React from 'react';
import { connect } from 'react-redux';
import reactForm from 'app/utils/ReactForm';
import tt from 'counterpart';
import * as userActions from 'app/redux/UserReducer';
import { validate_account_name } from 'app/utils/ChainValidation';
......@@ -9,27 +8,10 @@ import { validate_account_name } from 'app/utils/ChainValidation';
class WalletIndex extends React.Component {
constructor(props) {
super();
this.initForm(props);
}
initForm(props) {
reactForm({
name: 'login',
instance: this,
fields: ['username'],
initialValues: props.initialValues,
validation: values => ({
username: !values.username
? tt('g.required')
: validate_account_name(values.username.split('/')[0]),
}),
});
}
render() {
const { dispatchSubmit } = this.props;
const { username } = this.state;
const { submitting, valid, handleSubmit } = this.state.login;
const { showLogin, loggedIn } = this.props;
return (
<div className="WalletIndex">
<div className="row">
......@@ -38,36 +20,17 @@ class WalletIndex extends React.Component {
{tt('wallet_index.title')}
</h3>
<p>{tt('wallet_index.description')}</p>
<form
method="post"
onSubmit={handleSubmit(({ data }) => {
dispatchSubmit(data);
})}
>
<div className="input-group">
<input
type="text"
className="input-group-field"
required
placeholder={tt(
'loginform_jsx.enter_your_username'
)}
ref="username"
name="username"
autoComplete="on"
{...username.props}
/>
</div>
{loggedIn ? null : (
<div className="modal-buttons">
<button
type="submit"
disabled=""
className="button"
onClick={showLogin}
>
{tt('wallet_index.login')}
</button>
</div>
</form>
)}
</div>
<div className="column tokens">
<div className="sheet-container">
......@@ -137,18 +100,19 @@ module.exports = {
path: ':order(/:category)',
component: connect(
(state, ownProps) => {
const username = state.user.getIn(['current', 'username']);
const loggedIn = !!username;
const initialValues = {};
return {
initialValues,
loggedIn,
};
},
dispatch => {
return {
dispatchSubmit: data => {
const payload = Object.assign({}, data, {
operationType: 'username',
});
dispatch(userActions.usernamePasswordLogin(payload));
showLogin: e => {
if (e) e.preventDefault();
dispatch(userActions.showLogin({ type: 'basic' }));
},
};
}
......
......@@ -695,23 +695,23 @@
"You account has been successfully created!",
"you_account_has_been_successfully_recovered":
"You account has been successfully recovered!",
"password_update_succes":
"password_update_success":
"The password for %(accountName)s was successfully updated",
"password_info":
"This password or private key was entered incorrectly. There is probably a handwriting or data-entry error. Hint: A password or private key generated by Steemit will never contain 0 (zero), O (capital o), I (capital i) and l (lower case L) characters.",
"enter_your_username": "Enter your username",
"enter_steem_key": "Enter a Steem key (ideally your Posting Key)",
"password_or_wif": "Password or WIF",
"this_operation_requires_your_key_or_master_password":
"This operation requires your %(authType)s key or Master password.",
"keep_me_logged_in": "Keep me logged in",
"amazing_community": "amazing community",
"to_comment_and_reward_others": " to comment and reward others.",
"signup_button": "Sign up now to earn ",
"signup_button_emphasis": "FREE STEEM!",
"sign_up_get_steem": "Sign up. Get STEEM!",
"sign_up_get_steem": "Sign up",
"returning_users": "Returning Users: ",
"join_our": "Join our",
"sign_transfer": "Sign to complete transfer"
"login_to_wallet": "Login to Wallet",
"sign_transfer": "Sign to complete transfer",
"dont_have_an_account": "Don't have a Steem account?"
},
"chainvalidation_js": {
"account_name_should_not_be_empty": "Account name should not be empty.",
......@@ -871,13 +871,13 @@
"title": "Steem wallet login",
"description":
"Welcome to Steemit's official Steem blockchain wallet. Use it to transfer Steem tokens, Power up, vote for Steem Witnesses and change your Steem profile details.",
"login": "View Account",
"login": "Login",
"steem_tokens": "Steem tokens",
"steem_symbol": "STEEM",
"steem_description": "Liquid platform token",
"steem_power_symbol": "STEEM Power",
"steem_power_description": "Vesting influence token",
"sbd_symbol": "SBD",
"sbd_description": "Vesting influence token"
"sbd_description": "Seeks price stability with USD"
}
}
......@@ -605,7 +605,7 @@
"Tu cuenta se ha creado con éxito!",
"you_account_has_been_successfully_recovered":
"Tu cuenta ha sido recuperada con éxito!",
"password_update_succes":
"password_update_success":
"La contraseña %(accountName)s ha sido cambiada correctamente",
"password_info":
"La contraseña o la contraseña privada fue introducida incorrectamente. Probablemente. Ayuda: Las contraseñas generadas por Steemit nunca contendrán 0 (cero), O (o mayúscula), I (i mayúscula), l (L minúscula).",
......@@ -614,13 +614,10 @@
"this_operation_requires_your_key_or_master_password":
"Esta operación requiere %(authType)s contraseña o la contraseña maestra",
"keep_me_logged_in": "Manténme logeado",
"amazing_community": "comunidad increíble",
"to_comment_and_reward_others": "para comentar y recompensar a otros",
"sign_up_get_steem": "Crea una cuenta. Comienza en STEEM",
"signup_button": "Crea una cuenta, comienza a ganar ",
"signup_button_emphasis": "FREE STEEM!",
"returning_users": "Inicia sesion",
"join_our": "Únete a nuestro"
"returning_users": "Inicia sesion"
},
"chainvalidation_js": {
"account_name_should": "El nombre de la cuenta debería",
......
......@@ -626,7 +626,7 @@
"Votre compte a été créé avec succès!",
"you_account_has_been_successfully_recovered":
"Votre compte a été récupéré avec succès!",
"password_update_succes":
"password_update_success":
"Le mot de passe pour%(accountName)sa été mis à jour avec succès.",
"password_info":
"Ce mot de passe ou clé privée est incorrect. Il y a probablement une erreur d'écriture ou d'entrée des données. Indication : un mot de passe ou une clé privée générée par Steemit ne contiendra jamais aucun 0 (zéro), O (o majuscule), I (i majuscule) ou l (l minuscule).",
......@@ -635,14 +635,10 @@
"this_operation_requires_your_key_or_master_password":
"Cette opération nécessite votre clé %(authType)s ou votre mot de passe principal.",
"keep_me_logged_in": "Gardez-moi connecté",
"amazing_community": "communauté extraordinaire",
"to_comment_and_reward_others":
" pour commenter et récompenser les autres.",
"sign_up_get_steem": "Sign up. Get STEEM",
"signup_button": "Sign up now to earn ",
"signup_button_emphasis": "FREE STEEM!",
"returning_users": "Utilisateurs de retour: ",
"join_our": "Rejoignez notre"
"returning_users": "Utilisateurs de retour: "
},
"chainvalidation_js": {
"account_name_should": "Le nom du compte doit ",
......
......@@ -615,7 +615,7 @@
"Il tuo account è stato creato con successo! ",
"you_account_has_been_successfully_recovered":
"Il tuo account è stato ripristinato con successo!",
"password_update_succes":
"password_update_success":
"La password dell'account %(accountName)s è stata aggiornata con successo",
"password_info":
"La password o la chiave privata è stata inserita erroneamente. C'è probabilmente un errore di battitura o un inserimento di dati errato. Suggerimento: Una password o una chiave privata generata da Steemit non conterrà mai i caratteri 0 (zero), O (o maiuscola), I (i maiuscola) e l (l minuscola).",
......@@ -624,13 +624,10 @@
"this_operation_requires_your_key_or_master_password":
"Per eseguire l'operazione è necessaria la propria chiave %(authType)so Master password. ",
"keep_me_logged_in": "Voglio restare connesso",
"amazing_community": "una comunità incredibile",
"to_comment_and_reward_others": "per commentare e premiare gli altri. ",
"sign_up_get_steem": "Sign up. Get STEEM",
"signup_button": "Sign up now to earn ",
"signup_button_emphasis": "FREE STEEM!",
"returning_users": "Utenti di ritorno:",
"join_our": "Unisciti al nostro"
"returning_users": "Utenti di ritorno:"
},
"chainvalidation_js": {
"account_name_should": "Il nome account",
......
......@@ -607,7 +607,7 @@
"あなたのアカウントは作成済みです!",
"you_account_has_been_successfully_recovered":
"あなたのアカウントは正常に回復されました!",
"password_update_succes":
"password_update_success":
"%(accountName)sのパスワードは正常に更新されました。",
"password_info":
"入力したパスワードまたは秘密キーが間違っています。手入力したか、またはデータエラーがある可能性があります。ヒント:Steemitで生成したパスワードまたは秘密キーは0 (ゼロ)、O (大文字のo)、I (大文字のi)、l (小文字のL)を含みません。",
......@@ -616,14 +616,10 @@
"this_operation_requires_your_key_or_master_password":
"この操作には%(authType)sキーまたはマスターパスワードが必要です。",
"keep_me_logged_in": "ログイン状態を維持する",
"amazing_community": "素晴らしいコミュニティ",
"to_comment_and_reward_others":
"に参加して、他の人にコメントして報酬を与えましょう。",
"signup_button": "サインアップして",
"signup_button_emphasis": "STEEMを手に入れよう!",
"sign_up_get_steem": "登録してSTEEMを手に入れよう!",
"returning_users": "再",
"join_our": ""
"returning_users": "再"
},
"chainvalidation_js": {
"account_name_should": "アカウント名",
......
......@@ -606,7 +606,7 @@
"You account has been successfully created!",
"you_account_has_been_successfully_recovered":
"You account has been successfully recovered!",
"password_update_succes":
"password_update_success":
"The password for %(accountName)s was successfully updated",
"password_info":
"암호 또는 개인키가 잘못 입력되었습니다. 타자입력의 실수 또는 데이터 입력의 오류일 수 있습니다. 힌트: steemit 에서 생성된 암호 또는 개인키에는 0(숫자 0), O(영문자O), I(대문자I), l(소문자 L)을 절대로 포함하지 않습니다.",
......@@ -615,14 +615,11 @@
"this_operation_requires_your_key_or_master_password":
"이 작업은 %(authType)s 키 또는 마스터 비밀번호가 필요합니다.",
"keep_me_logged_in": "로그인 유지",
"amazing_community": "amazing community",
"to_comment_and_reward_others": " to comment and reward others.",
"signup_button": "Sign up now to earn ",
"signup_button_emphasis": "FREE STEEM!",
"sign_up_get_steem":
"계정을 만들고 가상화폐 STEEM 을 보상으로 받으세요.",
"returning_users": "Returning Users: ",