Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
birger
users
Commits
afd08ef2
Commit
afd08ef2
authored
Aug 12, 2018
by
o@immerda.ch
Browse files
rename trees to mail_crypt
parent
63217f0f
Changes
28
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/signup_helpers.js
View file @
afd08ef2
function
toggle
Trees
()
{
function
toggle
MailCrypt
()
{
q
=
document
.
getElementById
(
'
keep_recovery_token_question
'
);
if
(
document
.
getElementById
(
'
enable_
trees
'
).
checked
)
if
(
document
.
getElementById
(
'
enable_
mail_crypt
'
).
checked
)
q
.
style
.
display
=
'
block
'
;
else
q
.
style
.
display
=
'
none
'
;
}
function
loadPageActions
()
{
if
(
document
.
getElementById
(
'
enable_
trees
'
))
{
document
.
getElementById
(
'
enable_
trees
'
).
addEventListener
(
"
change
"
,
toggle
Trees
);
toggle
Trees
();
if
(
document
.
getElementById
(
'
enable_
mail_crypt
'
))
{
document
.
getElementById
(
'
enable_
mail_crypt
'
).
addEventListener
(
"
change
"
,
toggle
MailCrypt
);
toggle
MailCrypt
();
}
}
window
.
addEventListener
(
"
load
"
,
loadPageActions
)
app/assets/stylesheets/application.css
View file @
afd08ef2
...
...
@@ -48,12 +48,21 @@
border
:
dashed
gray
2px
;
}
.app-password
{
border
:
dashed
gray
3px
;
padding
:
10px
;
margin-top
:
20px
;
font-size
:
9pt
;
font-family
:
monospace
;
width
:
300px
;
}
.recovery-token
{
border
:
dashed
gray
3px
;
padding
:
10px
;
margin-top
:
20px
;
white-space
:
nowrap
;
font-
size
:
7.5pt
;
font-size
:
9pt
;
font-
family
:
monospace
;
}
.recovery-token
table
{
...
...
@@ -65,11 +74,11 @@
}
.recovery-token
td
{
border-left
:
solid
10
px
#000
;
border-left
:
solid
8
px
#000
;
padding
:
0
;
margin
:
0
;
width
:
0px
;
height
:
10
px
;
height
:
8
px
;
}
.recovery-token
td
.black
{
border-color
:
#000
;
}
...
...
app/assets/stylesheets/
trees
.scss
→
app/assets/stylesheets/
mail_crypt
.scss
View file @
afd08ef2
File moved
app/assets/stylesheets/
trees
_token.scss
→
app/assets/stylesheets/
mail_crypt
_token.scss
View file @
afd08ef2
File moved
app/controllers/application_controller.rb
View file @
afd08ef2
...
...
@@ -21,10 +21,10 @@ class ApplicationController < ActionController::Base
end
helper_method
:current_user
def
trees
_enabled?
session
[
:
trees
_enabled
]
def
mail_crypt
_enabled?
session
[
:
mail_crypt
_enabled
]
end
helper_method
:
trees
_enabled?
helper_method
:
mail_crypt
_enabled?
def
recovery_email_set?
session
[
:recovery_email_set
]
end
...
...
@@ -79,6 +79,6 @@ class ApplicationController < ActionController::Base
private
def
destroy_session
session
[
:user_id
]
=
nil
session
[
:
trees
_recovery_token
]
=
nil
session
[
:
mail_crypt
_recovery_token
]
=
nil
end
end
app/controllers/concerns/api_backend.rb
View file @
afd08ef2
...
...
@@ -135,11 +135,11 @@ module ApiBackend
post
([
'users'
,
'delete_account'
],
{
"email"
=>
user
,
"password"
=>
pw
})
end
def
self
.
trees
_enable
(
user
,
pw
)
post
([
'users'
,
'enable_
trees
'
],
{
"email"
=>
user
,
"password"
=>
pw
})
def
self
.
mail_crypt
_enable
(
user
,
pw
)
post
([
'users'
,
'enable_
mail_crypt
'
],
{
"email"
=>
user
,
"password"
=>
pw
})
end
def
self
.
trees
_token
(
user
,
pw
)
def
self
.
mail_crypt
_token
(
user
,
pw
)
post
([
'users'
,
'generate_recovery_token'
],
{
"email"
=>
user
,
"password"
=>
pw
})
end
...
...
@@ -151,21 +151,21 @@ module ApiBackend
post
([
'invites'
,
'generate'
],
{
"number"
=>
num
,
"expire"
=>
expire
,
"domains"
=>
domains
})
end
def
self
.
create_new_mailbox
(
email
,
pw
,
trees
_enabled
,
invite
,
recovery_email
,
keep_recovery_token
)
def
self
.
create_new_mailbox
(
email
,
pw
,
mail_crypt
_enabled
,
invite
,
recovery_email
,
keep_recovery_token
)
post
([
'users'
,
'create_new_mailbox'
],
{
"email"
=>
email
,
"password"
=>
pw
,
"
trees
_enabled"
=>
trees
_enabled
,
"
mail_crypt
_enabled"
=>
mail_crypt
_enabled
,
"invite"
=>
invite
,
"recovery_email"
=>
recovery_email
,
"keep_recovery_token"
=>
keep_recovery_token
,
})
end
def
self
.
create_new_mailbox_admin
(
email
,
pw
,
forward
,
trees
_enabled
,
recovery_email
,
keep_recovery_token
)
def
self
.
create_new_mailbox_admin
(
email
,
pw
,
forward
,
mail_crypt
_enabled
,
recovery_email
,
keep_recovery_token
)
post
([
'users_admin'
,
'create_new_mailbox'
],
{
"email"
=>
email
,
"password"
=>
pw
,
"forward"
=>
forward
,
"
trees
_enabled"
=>
trees
_enabled
,
"
mail_crypt
_enabled"
=>
mail_crypt
_enabled
,
"recovery_email"
=>
recovery_email
,
"keep_recovery_token"
=>
keep_recovery_token
,
})
...
...
app/controllers/
trees
_controller.rb
→
app/controllers/
mail_crypt
_controller.rb
View file @
afd08ef2
class
Trees
Controller
<
ApplicationController
class
MailCrypt
Controller
<
ApplicationController
def
update
if
(
p
=
params
[
:pass
]).
present?
begin
ApiBackend
::
trees
_enable
(
current_user
,
p
)
session
[
:
trees
_enabled
]
=
true
flash
[
:notice
]
=
:
trees
_enabled
redirect_to
'/
trees
_token'
and
return
ApiBackend
::
mail_crypt
_enable
(
current_user
,
p
)
session
[
:
mail_crypt
_enabled
]
=
true
flash
[
:notice
]
=
:
mail_crypt
_enabled
redirect_to
'/
mail_crypt
_token'
and
return
rescue
ApiBackend
::
ApiError
=>
e
if
e
.
api_msg
==
'auth_fail'
flash
[
:notice
]
=
:auth_fail
else
flash
[
:notice
]
=
:
trees
_enable_failed
flash
[
:notice
]
=
:
mail_crypt
_enable_failed
end
end
end
...
...
app/controllers/
trees
_token_controller.rb
→
app/controllers/
mail_crypt
_token_controller.rb
View file @
afd08ef2
class
Trees
TokenController
<
ApplicationController
class
MailCrypt
TokenController
<
ApplicationController
def
create
begin
res
=
ApiBackend
::
trees_token
(
current_user
,
params
[
:pass
])
@recovery_token
=
res
[
'trees_recovery_token'
]
@qr
=
RQRCode
::
QRCode
.
new
(
@recovery_token
,
:size
=>
12
,
:level
=>
:h
)
res
=
ApiBackend
::
mail_crypt_token
(
current_user
,
params
[
:pass
])
recovery_token
=
res
[
'mail_crypt_recovery_token'
]
@qr
=
RQRCode
::
QRCode
.
new
(
recovery_token
,
:size
=>
20
,
:level
=>
:h
)
@recovery_token
=
recovery_token
.
gsub
(
/(.{8})/
,
'\1<wbr>'
).
html_safe
rescue
ApiBackend
::
ApiError
=>
e
if
e
.
api_msg
==
'auth_fail'
flash
[
:notice
]
=
:auth_fail
...
...
app/controllers/sessions_controller.rb
View file @
afd08ef2
...
...
@@ -29,8 +29,8 @@ class SessionsController < ApplicationController
begin
res
=
ApiBackend
::
auth
(
params
[
:user_id
],
params
[
:password
],
query
)
session
[
:user_id
]
=
params
[
:user_id
]
session
[
:
trees
_recovery_token
]
=
nil
session
[
:
trees
_enabled
]
=
res
[
'
trees
_enabled'
]
session
[
:
mail_crypt
_recovery_token
]
=
nil
session
[
:
mail_crypt
_enabled
]
=
res
[
'
mail_crypt
_enabled'
]
session
[
:recovery_email_set
]
=
res
[
'recovery_email'
]
session
[
:pow_factor
]
=
1
update_session_expiry
...
...
@@ -43,7 +43,7 @@ class SessionsController < ApplicationController
if
@page
&&
!
(
@page
=~
/login/
||
@page
=~
/logout/
)
redirect_to
@page
else
if
trees
_enabled?
&&
res
[
'
trees
_recovery_token_present'
]
if
mail_crypt
_enabled?
&&
res
[
'
mail_crypt
_recovery_token_present'
]
flash
[
:notice
]
=
:recovery_token_hint
end
redirect_to
'/'
...
...
app/controllers/signup_controller.rb
View file @
afd08ef2
...
...
@@ -2,7 +2,7 @@ class SignupController < ApplicationController
def
new
if
@token
# on by default
@enable_
trees
=
true
@enable_
mail_crypt
=
true
render
'create'
else
render
'token'
...
...
@@ -13,7 +13,7 @@ class SignupController < ApplicationController
(
redirect_to
'/signup'
and
return
)
unless
@token
@email
=
params
[
:email
]
@new_pw
=
params
[
:new
]
@enable_
trees
=
params
[
:enable_
trees
]
@enable_
mail_crypt
=
params
[
:enable_
mail_crypt
]
@recovery_email
=
params
[
:recovery_email
]
@domain
=
params
[
:domain
]
@keep_recovery_token
=
params
[
:keep_recovery_token
]
...
...
@@ -42,17 +42,17 @@ class SignupController < ApplicationController
return
end
if
@enable_
trees
&&
!
@keep_recovery_token
if
@enable_
mail_crypt
&&
!
@keep_recovery_token
flash
[
:notice
]
=
:decide_recovery_token
return
end
begin
res
=
ApiBackend
::
create_new_mailbox
(
full_email
,
@new_pw
,
@enable_
trees
,
@token
,
full_email
,
@new_pw
,
@enable_
mail_crypt
,
@token
,
@recovery_email
,
@keep_recovery_token
==
'yes'
)
if
@keep_recovery_token
!=
'yes'
@
trees
_recovery_token
=
res
[
'
trees
_recovery_token'
]
@
mail_crypt
_recovery_token
=
res
[
'
mail_crypt
_recovery_token'
]
end
render
'success'
rescue
ApiBackend
::
ApiError
...
...
app/controllers/users_controller.rb
View file @
afd08ef2
...
...
@@ -20,7 +20,7 @@ class UsersController < AdminController
full_email
,
params
[
:password
],
params
[
:forward
],
params
[
:enable_
trees
],
params
[
:enable_
mail_crypt
],
params
[
:recovery_email
],
(
params
[
:keep_recovery_token
]
==
'yes'
)
)
...
...
@@ -34,7 +34,7 @@ class UsersController < AdminController
'alias'
=>
params
[
:alias
],
'domain'
=>
params
[
:domain
],
'password'
=>
params
[
:password
],
'enable_
trees
'
=>
params
[
:enable_
trees
],
'enable_
mail_crypt
'
=>
params
[
:enable_
mail_crypt
],
'recovery_email'
=>
params
[
:recovery_email
],
'keep_recovery_token'
=>
params
[
:keep_recovery_token
],
}
...
...
@@ -53,10 +53,10 @@ class UsersController < AdminController
[
:forward
,
params
[
:forward
]]
elsif
params
[
:password
]
[
:legacy_password
,
params
[
:password
]]
elsif
params
[
:
trees
_secret_box
]
&&
params
[
:
trees
_secret_box
].
length
==
189
[
:
trees
_secret_box
,
params
[
:
trees
_secret_box
]]
elsif
params
[
:
trees
_password_force
]
&&
params
[
:
trees
_password_force
].
length
>
6
[
:
trees
_force_password
,
params
[
:
trees
_password_force
]]
elsif
params
[
:
mail_crypt
_secret_box
]
&&
params
[
:
mail_crypt
_secret_box
].
length
==
189
[
:
mail_crypt
_secret_box
,
params
[
:
mail_crypt
_secret_box
]]
elsif
params
[
:
mail_crypt
_password_force
]
&&
params
[
:
mail_crypt
_password_force
].
length
>
6
[
:
mail_crypt
_force_password
,
params
[
:
mail_crypt
_password_force
]]
elsif
params
[
:quota
]
[
:mbxquota
,
params
[
:quota
]]
elsif
params
[
:recovery_email
]
&&
params
[
:recovery_email
]
=~
/@/
...
...
app/helpers/mail_crypt_helper.rb
0 → 100644
View file @
afd08ef2
module
MailCryptHelper
end
app/helpers/mail_crypt_token_helper.rb
0 → 100644
View file @
afd08ef2
module
MailCryptTokenHelper
end
app/helpers/trees_helper.rb
deleted
100644 → 0
View file @
63217f0f
module
TreesHelper
end
app/helpers/trees_token_helper.rb
deleted
100644 → 0
View file @
63217f0f
module
TreesTokenHelper
end
app/views/app_passwords/show.html.erb
View file @
afd08ef2
...
...
@@ -2,7 +2,9 @@
<%
if
@app_pw
%>
<b>
<%=
t
(
:your_app_pw_is
)
%>
</b>
<p>
<%=
@app_pw
%>
</p>
<p>
<div
class=
"app-password"
>
<%=
@app_pw
%>
</div>
</p>
<%
end
%>
<p>
<%=
t
:app_passwords_help
%>
...
...
app/views/
trees
/show.html.erb
→
app/views/
mail_crypt
/show.html.erb
View file @
afd08ef2
...
...
@@ -3,7 +3,7 @@
<%=
t
:encrypt_mailbox_help
%>
<%=
t
:encrypt_mailbox_help_existing
%>
</p>
<%=
form_tag
(
trees
_path
,
method:
"post"
)
do
%>
<%=
form_tag
(
mail_crypt
_path
,
method:
"post"
)
do
%>
<%=
label_tag
(
:pass
,
(
t
:password_for_enable
))
%>
<%=
password_field_tag
(
:pass
)
%>
<%=
submit_tag
(
t
:activate
)
%>
...
...
app/views/
trees
_token/show.html.erb
→
app/views/
mail_crypt
_token/show.html.erb
View file @
afd08ef2
...
...
@@ -8,6 +8,7 @@
<b>
<%=
t
(
:token
)
%>
</b>
<div
class=
"recovery-token"
>
<%=
@recovery_token
%>
</div>
</p>
<br
/>
<p>
<b>
<%=
t
(
:qr_code
)
%>
</b>
<div
class=
"recovery-token"
>
<%=
raw
(
@qr
.
as_html
)
%>
</div>
...
...
@@ -19,7 +20,7 @@
<%=
t
:recovery_token_help
%>
</p>
<%=
form_tag
(
trees
_token_path
,
method:
"post"
)
do
%>
<%=
form_tag
(
mail_crypt
_token_path
,
method:
"post"
)
do
%>
<%=
label_tag
(
:pass
,
(
t
:password_for_reveal
))
%>
<%=
password_field_tag
(
:pass
)
%>
<br
/>
...
...
app/views/signup/create.html.erb
View file @
afd08ef2
...
...
@@ -41,8 +41,8 @@
<br
/>
<p>
<input
type=
"checkbox"
id=
"enable_
trees
"
name=
"enable_
trees
"
value=
"true"
<%=
if
@enable_
trees
then
'checked="checked"'
else
''
end
%>
/>
<input
type=
"checkbox"
id=
"enable_
mail_crypt
"
name=
"enable_
mail_crypt
"
value=
"true"
<%=
if
@enable_
mail_crypt
then
'checked="checked"'
else
''
end
%>
/>
<b>
<%=
t
:encrypt_mailbox
%>
</b>
<br/>
<%=
t
:encrypt_mailbox_help
%>
...
...
app/views/signup/success.html.erb
View file @
afd08ef2
...
...
@@ -6,12 +6,12 @@
<%=
t
(
:new_account_intro1
)
%>
</p>
<%
if
@
trees
_recovery_token
%>
<%
if
@
mail_crypt
_recovery_token
%>
<p>
<%=
t
(
:new_account_intro_token
)
%>
<br
/>
<br
/>
<b>
Token
</b>
<div
class=
"recovery-token"
>
<%=
@
trees
_recovery_token
%>
</div>
<b>
Token
</b>
<div
class=
"recovery-token"
>
<%=
@
mail_crypt
_recovery_token
%>
</div>
</p>
<p>
...
...
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment