Commit afd08ef2 authored by o@immerda.ch's avatar o@immerda.ch
Browse files

rename trees to mail_crypt

parent 63217f0f
function toggleTrees() {
function toggleMailCrypt() {
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", toggleTrees);
toggleTrees();
if (document.getElementById('enable_mail_crypt')) {
document.getElementById('enable_mail_crypt').addEventListener("change", toggleMailCrypt);
toggleMailCrypt();
}
}
window.addEventListener("load", loadPageActions)
......@@ -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 10px #000;
border-left: solid 8px #000;
padding: 0;
margin: 0;
width: 0px;
height: 10px;
height: 8px;
}
.recovery-token td.black { border-color: #000; }
......
......@@ -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
......@@ -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,
})
......
class TreesController < ApplicationController
class MailCryptController < 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
......
class TreesTokenController < ApplicationController
class MailCryptTokenController < 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
......
......@@ -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 '/'
......
......@@ -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
......
......@@ -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] =~ /@/
......
module MailCryptHelper
end
module MailCryptTokenHelper
end
......@@ -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 %>
......
......@@ -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) %>
......
......@@ -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 />
......
......@@ -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 %>
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment