Skip to content

Commit 4518a97

Browse files
committed
Merge branch 'master' of github.com:RocketChat/Rocket.Chat
2 parents eb254b2 + 738f48f commit 4518a97

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

client/views/login/form.coffee

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ Template.loginForm.helpers
1111
showConfirmPassword: ->
1212
return 'hidden' unless Template.instance().state.get() is 'register'
1313

14+
showEmailOrUsername: ->
15+
return 'hidden' unless Template.instance().state.get() is 'login'
16+
17+
showEmail: ->
18+
return 'hidden' unless Template.instance().state.get() in ['register', 'forgot-password', 'email-verification']
19+
1420
showRegisterLink: ->
1521
return 'hidden' unless Template.instance().state.get() is 'login'
1622

@@ -64,7 +70,7 @@ Template.loginForm.events
6470
else
6571
Router.go 'index'
6672
else
67-
Meteor.loginWithPassword formData.email, formData.pass, (error) ->
73+
Meteor.loginWithPassword formData.emailOrUsername, formData.pass, (error) ->
6874
Rocket.Button.reset(button)
6975
if error?
7076
if error.error is 'no-valid-email'
@@ -94,9 +100,10 @@ Template.loginForm.onCreated ->
94100
for field in formData
95101
formObj[field.name] = field.value
96102

97-
unless formObj['email'] and /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+\b/i.test(formObj['email'])
98-
validationObj['email'] = t('login.Invalid_email')
99-
103+
if instance.state.get() isnt 'login'
104+
unless formObj['email'] and /\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+\b/i.test(formObj['email'])
105+
validationObj['email'] = t('login.Invalid_email')
106+
100107
if instance.state.get() isnt 'forgot-password'
101108
unless formObj['pass']
102109
validationObj['pass'] = t('login.Invalid_pass')

client/views/login/form.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ <h2>{{_ "login.Enter_info"}}</h2>
1515
<i></i>
1616
</div>
1717
</div>
18-
<div class='input-text active'>
18+
<div class='input-text active {{showEmailOrUsername}}'>
19+
<div class='field'>
20+
<span>
21+
<input type="text" name='emailOrUsername' placeholder='{{_ "login.Email_or_username"}}' />
22+
</span>
23+
<i></i>
24+
</div>
25+
</div>
26+
<div class='input-text active {{showEmail}}'>
1927
<div class='field'>
2028
<span>
2129
<input type="email" name='email' placeholder='{{_ "Email"}}' />

i18n/en.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"Cancel": "Back to login",
9393
"Confirm_password": "Confirm your password",
9494
"Enter_info": "Enter your login information",
95+
"Email_or_username": "Email or username",
9596
"Forgot_password": "Forgot your password",
9697
"Password": "Password",
9798
"Register": "Register a new account",

i18n/pt.i18n.json

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
"Cancel": "Voltar para o login",
9090
"Confirm_password": "Confirmar a senha",
9191
"Enter_info": "Entre com seus dados de login",
92+
"Email_or_username": "Email ou nome de usuário",
9293
"Forgot_password": "Esqueceu sua senha",
9394
"Password": "Senha",
9495
"Register": "Registrar-se",

0 commit comments

Comments
 (0)