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

cleanup

* style pages which were not adapted yet
* streamline design (e.g. use the same forms everywhere)
* use less colors
* various fixes
* re-add token generation menu entry
* fix signup page to not show menu
parent bbf30c18
......@@ -146,9 +146,6 @@
padding: 10px;
margin-top: 20px;
font-family: monospace;
background-color: white;
color: black;
border: dashed gray 3px;
width: auto;
}
......@@ -156,32 +153,6 @@
padding: 2px;
}
table.pgpkeys {
width: 100%;
text-align: center;
}
pre.pgpkey-description {
display: inline-block;
text-align: left;
margin: 0 1em 0 0;
width: 85%;
}
form.pgpkeys-upload {
margin: 3em 0 0 0;
padding: 1em;
border: solid thin grey;
}
.pgpkeys-error-message {
display: inline-block;
border: solid thin red;
color: red;
font-weight: bold;
padding: 1em;
margin: 2em 0 -2em;
}
.logo {
height: 97px;
width: 135px;
......
......@@ -4,10 +4,3 @@ a {
a.list-group-item {
font-weight: normal;
}
* {
border-radius: 0;
}
.card {
border: none;
}
$igreen: #60d545;
$box: #cdc;
$box: #b4d5ad;
$bg: #222;
$fg: #fcfcfc;
......
.webauthn-form div {
float: left;
padding-right: 15px;
}
.webauthn-form table {
padding-top: 5px;
}
......@@ -5,7 +5,7 @@ class AclController < AdminController
begin
@acl = api.acl_show
rescue ApiBackend::ApiError => e
flash[:notice] = e.api_msg
flash[:danger] = e.api_msg
end
end
end
class AdminController < ApplicationController
def authorize
if !admin?
flash[:notice] = :login_failed
flash[:danger] = :login_failed
reset_user_session
redirect_to '/login'
else
......
......@@ -18,7 +18,7 @@ class AppPasswordsController < ApplicationController
session[:app_pw] = nil
end
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to root_path
end
end
......@@ -30,16 +30,16 @@ class AppPasswordsController < ApplicationController
params[:password], params[:app_name])
session[:app_pw] = res['app_pw']
rescue ApiBackend::ApiError => e
flash[:notice] = e.api_msg || :failed
flash[:danger] = e.api_msg || :failed
end
elsif params[:delete]
begin
api.app_password_delete(params[:delete])
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
end
else
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to root_path and return
end
redirect_to app_passwords_path
......
......@@ -71,6 +71,10 @@ class ApplicationController < ActionController::Base
session[:recovery_email_set]
end
helper_method :recovery_email_set?
def no_recovery_token_requested?
session[:mail_crypt_recovery_token_present]
end
helper_method :no_recovery_token_requested?
def requires_2fa?
session[:requires_2fa]
......@@ -107,19 +111,20 @@ class ApplicationController < ActionController::Base
if login
if res['locked']
flash[:notice] = :locked_account_hint
flash[:info] = :locked_account_hint
elsif res['mail_crypt_enabled'] &&
res['mail_crypt_recovery_token_present']
flash[:notice] = :recovery_token_hint
flash[:info] = :recovery_token_hint
elsif res['mail_crypt_enabled'] &&
!session[:recovery_email_set]
# TODO: add translations
# flash[:notice] = :recovery_email_hint
# flash[:info] = :recovery_email_hint
else
flash[:notice] = nil
flash.discard
end
end
session[:mail_crypt_recovery_token_present] = res['mail_crypt_recovery_token_present']
session[:mail_crypt_enabled] = res['mail_crypt_enabled']
session[:recovery_email_set] = res['recovery_email_set']
session[:requires_2fa] = res['requires_2fa']
......@@ -168,11 +173,11 @@ class ApplicationController < ActionController::Base
def password_policy?(pw)
if pw.length < 10
flash[:notice] = :password_too_short
flash[:warning] = :password_too_short
return false
end
if Zxcvbn.test(pw).score < 3
flash[:notice] = :password_policy_fail
flash[:warning] = :password_policy_fail
return false
end
true
......@@ -214,4 +219,9 @@ class ApplicationController < ActionController::Base
def msg
end
def signup?
false
end
helper_method :signup?
end
......@@ -5,14 +5,14 @@ class DeleteAccountController < ApplicationController
if (p = params[:pass]).present?
begin
api.delete_account(p)
flash[:notice] = :delete_success
flash[:success] = :delete_success
reset_user_session
redirect_to '/' and return
rescue ApiBackend::ApiError => e
if e.api_msg == 'auth_fail'
flash[:notice] = :auth_fail
flash[:danger] = :auth_fail
else
flash[:notice] = :failed
flash[:danger] = :failed
end
end
end
......
......@@ -20,7 +20,7 @@ class DomainsController < AdminController
api.update_domain(@domain['domain'], values)
redirect_to '/domains' and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
@domain = values.merge({'domain' => @domain['domain'] })
render 'edit'
end
......@@ -29,7 +29,7 @@ class DomainsController < AdminController
api.delete_domain(@domain['domain'])
redirect_to domains_path and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
end
def create
......@@ -42,7 +42,7 @@ class DomainsController < AdminController
api.create_domain(params[:domain], values)
redirect_to domains_path and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
@domain = values.merge({'domain' => params[:domain] })
render 'new'
end
......@@ -51,7 +51,7 @@ class DomainsController < AdminController
def fetch_domain
@domain = api.get_domain(params[:domain])['domain']
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to domains_path
end
end
......@@ -15,9 +15,9 @@ class InvitesController < AdminController
@tokens = res['tokens']
rescue ApiBackend::ApiError => e
if e.api_msg == 'invalid_domain'
flash[:notice] = :invalid_domain
flash[:danger] = :invalid_domain
else
flash[:notice] = :failed
flash[:danger] = :failed
end
end
end
......
......@@ -8,14 +8,14 @@ class JabberController < ApplicationController
@jids = api_res['jids']
@possible_jids = api_res['possible_jids']
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to root_path
end
def show
@jid = api.jabber_get_jid(params[:jid])
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to jabber_path
end
......@@ -23,7 +23,7 @@ class JabberController < ApplicationController
@jid = api.jabber_reset_password(params[:jid])
render :show
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to jabber_path
end
......@@ -32,9 +32,9 @@ class JabberController < ApplicationController
redirect_to jabber_path and return
rescue ApiBackend::ApiError => e
if ['failed','auth_fail'].include?(e.api_msg)
flash[:notice] = e.api_msg
flash[:danger] = e.api_msg
else
flash[:notice] = :failed
flash[:danger] = :failed
end
redirect_to jabber_path
end
......@@ -43,7 +43,7 @@ class JabberController < ApplicationController
@jid = api.jabber_create(params[:jid_alias], params[:domain])
render :show
rescue ApiBackend::ApiError => e
flash[:notice] = e.api_msg
flash[:danger] = e.api_msg
redirect_to jabber_path
end
......@@ -51,13 +51,13 @@ class JabberController < ApplicationController
def fetch_public_domains
@public_jabber_domains = api.jabber_domains_public
rescue ApiBackend::ApiError
flash[:notice] = :failed
flash[:danger] = :failed
redirect_to root_path
end
def ensure_jabber_enabled?
unless resource_enabled?('jabber')
flash[:notice] = :service_not_available
flash[:danger] = :service_not_available
redirect_to root_path
end
end
......
......@@ -21,7 +21,7 @@ class JabberDomainsController < AdminController
redirect_to jabber_domains_path and return
redirect_to '/domains' and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
render 'edit'
end
......@@ -29,7 +29,7 @@ class JabberDomainsController < AdminController
api.jabber_delete_domain(@domain['domain'])
redirect_to jabber_domains_path and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
end
def create
......@@ -40,7 +40,7 @@ class JabberDomainsController < AdminController
)
redirect_to jabber_domains_path and return
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
@domain = params
render 'new'
end
......@@ -49,13 +49,13 @@ class JabberDomainsController < AdminController
def fetch_domain
@domain = api.jabber_get_domain(params[:domain])['domain']
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to jabber_domains_path
end
def fetch_jabberhosts
@jabberhosts = api.jabber_get_jabberhosts
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to jabber_domains_path
end
end
......@@ -9,7 +9,7 @@ class JabberIdsController < AdminController
res = api.jabber_get_jids_admin(filter: @filter, domain: @domain, deleted: @deleted)
@jids = res['jids']
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to root_path
end
end
......@@ -17,7 +17,7 @@ class JabberIdsController < AdminController
def show
@jid = api.jabber_get_jid(params[:jid], nil, true)
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to jabber_ids_path
end
......@@ -29,7 +29,7 @@ class JabberIdsController < AdminController
end
redirect_to jabber_ids_path
rescue ApiBackend::ApiError
flash[:notice] = :fail
flash[:danger] = :fail
redirect_to jabber_ids_path
end
end
......@@ -4,12 +4,12 @@ class MailCryptController < ApplicationController
def enable
@keep_recovery_token = params[:keep_recovery_token]
if !@keep_recovery_token
flash[:notice] = :decide_recovery_token
flash[:warning] = :decide_recovery_token
elsif (p = params[:pass]).present?
begin
api.mail_crypt_enable(p)
update_account_properties
flash[:notice] = :mail_crypt_enabled
flash[:success] = :mail_crypt_enabled
if @keep_recovery_token == 'yes'
redirect_to '/mail_crypt_token' and return
else
......@@ -17,9 +17,9 @@ class MailCryptController < ApplicationController
end
rescue ApiBackend::ApiError => e
if e.api_msg == 'auth_fail'
flash[:notice] = :auth_fail
flash[:danger] = :auth_fail
else
flash[:notice] = :mail_crypt_enable_failed
flash[:danger] = :mail_crypt_enable_failed
end
end
end
......@@ -38,14 +38,14 @@ class MailCryptController < ApplicationController
end
@recovery_token = recovery_token.gsub(/(.{8})/, '\1<wbr>').html_safe
update_account_properties
unless flash[:notice] == :mail_crypt_enabled
flash[:notice] = nil
unless flash[:success] == :mail_crypt_enabled
flash.discard
end
rescue ApiBackend::ApiError => e
if e.api_msg == 'auth_fail'
flash[:notice] = :auth_fail
flash[:danger] = :auth_fail
else
flash[:notice] = :get_token_failed
flash[:danger] = :get_token_failed
end
end
render 'show'
......
......@@ -6,19 +6,19 @@ class PasswordController < ApplicationController
redirect_to '/password' and return
end
if params['new'] != params['confirm']
flash[:notice] = :password_change_mismatch
flash[:danger] = :password_change_mismatch
redirect_to '/password' and return
end
if params['new'] == params['old']
flash[:notice] = :password_policy_fail
flash[:warning] = :password_policy_fail
end
begin
api.change_password(params['old'], params['new'])
rescue ApiBackend::ApiError => e
if e.api_msg == 'auth_fail'
flash[:notice] = :auth_fail
flash[:danger] = :auth_fail
else
flash[:notice] = :password_change_failed
flash[:danger] = :password_change_failed
end
redirect_to '/password' and return
end
......
......@@ -3,15 +3,15 @@ class PgpkeysController < ApplicationController
@pgpkey_description = get_key(current_user)
rescue => exc
log_exception(exc)
flash.now[:error] = exception_to_flash_message(exc)
flash.now[:notice] = :failed
flash[:verbatim] = exception_to_flash_message(exc)
flash[:danger] = :failed
render 'index'
end
def create
key_material = params[:pgpkey].read
WkdSrvClient.post(current_user, key_material)
flash[:notice] = :pgpkeys_key_published
flash[:success] = :pgpkeys_key_published
rescue => exc
handle_exception(exc)
ensure
......@@ -20,7 +20,7 @@ class PgpkeysController < ApplicationController
def delete
WkdSrvClient.delete(current_user)
flash[:notice] = :pgpkeys_key_deleted
flash[:success] = :pgpkeys_key_deleted
rescue => exc
handle_exception(exc)
ensure
......@@ -38,8 +38,8 @@ class PgpkeysController < ApplicationController
end
def handle_exception(exc)
flash[:error] = exception_to_flash_message(exc)
flash[:notice] = :failed
flash[:verbatim] = exception_to_flash_message(exc)
flash[:danger] = :failed
log_exception(exc)
end
......@@ -64,7 +64,7 @@ class PgpkeysController < ApplicationController
output
else
logger.error "Process 'gpg' failed with errors: #{errors}"
flash.now[:notice] = :failed
flash.now[:danger] = :failed
nil
end
end
......
......@@ -6,19 +6,19 @@ class RecoveryEmailController < ApplicationController
@recovery_email = params[:recovery_email]
if !EmailValidation::check_external_email(@recovery_email)
flash[:notice] = :invalid_recovery_email
flash[:danger] = :invalid_recovery_email
render 'show' and return
end
api.set_recovery_email(@recovery_email, @email_recovery_token, params[:password])
flash[:notice] = :success
flash[:success] = :success
update_account_properties
redirect_to recovery_email_path
rescue ApiBackend::ApiError => e
if e.api_msg
flash[:notice] = e.api_msg
flash[:danger] = e.api_msg
else
flash[:notice] = :failed
flash[:danger] = :failed
end
render 'show'
end
......
......@@ -26,7 +26,7 @@ class SamlController < SessionsController
return
end
end
flash[:notice] ||= :login_failed
flash[:danger] ||= :login_failed
redirect_to '/'
end
......
......@@ -52,7 +52,7 @@ class SessionsController < ApplicationController
return true
end
rescue ApiBackend::ApiError => e
flash[:notice] = e.api_msg || :failed
flash[:danger] = e.api_msg || :failed
end
end
return false
......
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