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
5ac149f0
Commit
5ac149f0
authored
May 14, 2021
by
o@immerda.ch
Browse files
update interface to create/delete new-style aliases
parent
2517c5a4
Changes
30
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/email_forward.js
0 → 100644
View file @
5ac149f0
function
enableDelete
()
{
document
.
getElementById
(
'
enable_delete_form
'
).
style
.
display
=
'
none
'
;
document
.
getElementById
(
'
delete_form
'
).
style
.
display
=
'
block
'
;
}
function
loadActions
()
{
if
(
document
.
getElementById
(
'
enable_delete_form
'
))
document
.
getElementById
(
'
enable_delete_form
'
).
addEventListener
(
"
click
"
,
enableDelete
);
}
window
.
addEventListener
(
"
load
"
,
loadActions
)
app/assets/javascripts/userlist.js
View file @
5ac149f0
...
...
@@ -13,8 +13,6 @@ function enableOverride() {
}
function
loadActions
()
{
if
(
document
.
getElementById
(
'
only_mailbox
'
))
document
.
getElementById
(
'
only_mailbox
'
).
addEventListener
(
"
change
"
,
action
)
if
(
document
.
getElementById
(
'
enable_delete_form
'
))
document
.
getElementById
(
'
enable_delete_form
'
).
addEventListener
(
"
click
"
,
enableDelete
);
if
(
document
.
getElementById
(
'
enable_override_form
'
))
...
...
app/controllers/app_passwords_controller.rb
View file @
5ac149f0
class
AppPasswordsController
<
ApplicationController
include
ApiBackend
before_action
:requires_secured_mailstorage
def
show
...
...
app/controllers/application_controller.rb
View file @
5ac149f0
require
'zxcvbn'
class
ApplicationController
<
ActionController
::
Base
include
ApiBackend
protect_from_forgery
with: :exception
# Happens when api token times out
...
...
@@ -114,8 +116,7 @@ class ApplicationController < ActionController::Base
helper_method
:any_resource_exists?
def
list_of_canonical_resources
# TODO: move to api
[
'mailman'
,
'schleuder'
]
@@resource_types
||=
api
.
resource_available
end
helper_method
:list_of_canonical_resources
...
...
@@ -124,10 +125,12 @@ class ApplicationController < ActionController::Base
name
=
uid
.
split
(
":"
,
2
)[
1
]
localpart
=
name
.
split
(
"@"
,
2
)[
0
]
# TODO: move to api
{
available
=
{
mailman:
"https://lists.immerda.ch/mailman/admin/%{localpart}"
,
schleuder:
"https://schleuder.immerda.ch/lists/%{name}"
}[
which
.
to_sym
]
%
{
name:
name
,
localpart:
localpart
}
}
return
unless
available
[
which
.
to_sym
]
available
[
which
.
to_sym
]
%
{
name:
name
,
localpart:
localpart
}
end
helper_method
:canonical_resources_edit_link
...
...
app/controllers/concerns/api_backend.rb
View file @
5ac149f0
...
...
@@ -304,21 +304,23 @@ module ApiBackend
'value'
=>
value
})
end
def
list
(
filter
=
nil
,
domain
=
nil
,
mailbox
=
nil
,
deleted
=
nil
)
def
list
(
filter
=
nil
,
domain
=
nil
,
deleted
=
nil
)
get
([
'users_admin'
,
'list'
],
{
'filter'
=>
filter
,
'domain'
=>
domain
,
'mailbox'
=>
mailbox
,
'deleted'
=>
deleted
,})
end
def
list_forwards
(
filter
=
nil
,
domain
=
nil
)
get
([
'users_admin'
,
'list_forwards'
],
{
'filter'
=>
filter
,
'domain'
=>
domain
})
end
def
create_new_mailbox_admin
(
email
,
pw
,
forward
,
mail_crypt_enabled
,
recovery_email
,
keep_recovery_token
,
storagehost
)
def
create_new_mailbox_admin
(
email
,
pw
,
mail_crypt_enabled
,
recovery_email
,
keep_recovery_token
,
storagehost
)
post
([
'users_admin'
,
'create_new_mailbox'
],
{
"email"
=>
email
,
"password"
=>
pw
,
"forward"
=>
forward
,
"storagehost"
=>
storagehost
,
"mail_crypt_enabled"
=>
mail_crypt_enabled
,
"recovery_email"
=>
recovery_email
,
...
...
@@ -326,16 +328,24 @@ module ApiBackend
})
end
def
create_new_forward_admin
(
email
,
forwards
)
def
create_new_forward_admin
(
email
,
target
)
post
([
'users_admin'
,
'create_new_forward'
],
{
"email"
=>
email
,
"forwards"
=>
forwards
})
"target"
=>
target
})
end
def
delete_forward_admin
(
uid
)
post
([
'users_admin'
,
'delete_forward'
],
{
"uid"
=>
uid
})
end
def
acl_show
()
get
[
'acl'
,
'show'
]
end
def
resource_available
get
([
'resource'
,
'available'
])[
'available'
]
end
def
my_resources
()
get
[
'resource'
,
'mine'
]
end
...
...
app/controllers/delete_account_controller.rb
View file @
5ac149f0
class
DeleteAccountController
<
ApplicationController
include
ApiBackend
def
delete
if
(
p
=
params
[
:pass
]).
present?
begin
...
...
app/controllers/domains_controller.rb
View file @
5ac149f0
class
DomainsController
<
AdminController
include
ApiBackend
before_action
:fetch_domain
,
:only
=>
[
'delete'
,
'edit'
,
'update'
]
def
index
@domains
=
api
.
list_domains
...
...
app/controllers/email_forward_controller.rb
0 → 100644
View file @
5ac149f0
class
EmailForwardController
<
AdminController
def
index
@filter
=
params
[
:filter
].
present?
?
params
[
:filter
]
:
nil
@domain
=
params
[
:domain
].
present?
?
params
[
:domain
]
:
nil
begin
res
=
api
.
list_forwards
(
@filter
,
@domain
)
@entries
=
res
[
'entries'
]
rescue
ApiBackend
::
ApiError
flash
[
:danger
]
=
:fail
end
end
def
edit
@type
,
uid
=
params
[
:uid
].
split
(
':'
,
2
)
uid
=
uid
.
split
(
"@"
)
@uid
=
uid
.
join
(
"@"
)
@from
=
"
#{
uid
[
0
]
}
@
#{
uid
[
1
]
}
"
@to
=
"
#{
uid
[
2
]
}
@
#{
uid
[
3
]
}
"
end
def
update
if
params
[
:delete
]
api
.
delete_forward_admin
(
params
[
:uid
])
flash
[
:success
]
=
:success
else
flash
[
:danger
]
=
:not_implemented
end
redirect_to
email_forward_path
end
def
create
full_email
=
"
#{
params
[
:alias
]
}
@
#{
params
[
:domain
]
}
"
api
.
create_new_forward_admin
(
full_email
,
params
[
:forward
])
redirect_to
email_forward_path
and
return
rescue
ApiBackend
::
ApiError
=>
e
flash
[
:danger
]
=
e
.
api_msg
||
:failed
fetch_deps
render
'new'
end
def
new
fetch_deps
end
private
def
fetch_deps
@domains
=
api
.
list_domains
rescue
ApiBackend
::
ApiError
flash
[
:danger
]
=
:fail
redirect_to
email_forward_path
end
end
app/controllers/invites_controller.rb
View file @
5ac149f0
class
InvitesController
<
ApplicationController
include
ApiBackend
def
show
e
=
params
[
'expire'
]
e
=
"
#{
e
[
"by(1i)"
]
}
-
#{
e
[
"by(2i)"
]
}
-
#{
e
[
"by(3i)"
]
}
"
...
...
app/controllers/jabber_controller.rb
View file @
5ac149f0
class
JabberController
<
ApplicationController
include
ApiBackend
before_action
:ensure_jabber_enabled?
before_action
:fetch_public_domains
,
:only
=>
[
'index'
]
def
index
...
...
app/controllers/jabber_domains_controller.rb
View file @
5ac149f0
class
JabberDomainsController
<
AdminController
include
ApiBackend
before_action
:fetch_domain
,
:only
=>
[
'delete'
,
'edit'
,
'update'
]
before_action
:fetch_jabberhosts
,
:only
=>
[
'new'
,
'create'
,
'delete'
,
'edit'
,
'update'
]
def
index
...
...
app/controllers/jabber_ids_controller.rb
View file @
5ac149f0
class
JabberIdsController
<
AdminController
include
ApiBackend
def
index
@filter
=
params
[
:filter
].
present?
?
params
[
:filter
]
:
nil
@domain
=
params
[
:domain
].
present?
?
params
[
:domain
]
:
nil
...
...
app/controllers/mail_crypt_controller.rb
View file @
5ac149f0
class
MailCryptController
<
ApplicationController
include
ApiBackend
def
enable
@keep_recovery_token
=
params
[
:keep_recovery_token
]
if
!
@keep_recovery_token
...
...
app/controllers/password_controller.rb
View file @
5ac149f0
class
PasswordController
<
ApplicationController
include
ApiBackend
def
update
if
!
password_policy?
(
params
[
:new
])
redirect_to
'/password'
and
return
...
...
app/controllers/recovery_email_controller.rb
View file @
5ac149f0
class
RecoveryEmailController
<
ApplicationController
include
ApiBackend
def
update
@email_recovery_token
=
params
[
:email_recovery_token
].
present?
@recovery_email
=
params
[
:recovery_email
]
...
...
app/controllers/reserved_identifiers_controller.rb
View file @
5ac149f0
class
ReservedIdentifiersController
<
ApplicationController
include
ApiBackend
def
resource_list
[
'schleuder'
,
'mailman'
]
end
...
...
app/controllers/resources_admin_controller.rb
View file @
5ac149f0
class
ResourcesAdminController
<
ApplicationController
include
ApiBackend
def
resource_list
[
'schleuder'
,
'mailman'
]
list_of_canonical_resources
end
helper_method
:resource_list
...
...
app/controllers/resources_controller.rb
View file @
5ac149f0
class
ResourcesController
<
ApplicationController
include
ApiBackend
def
show
if
list_of_canonical_resources
.
include?
params
[
:kind
]
@resource_name
=
params
[
:kind
]
...
...
app/controllers/sessions_controller.rb
View file @
5ac149f0
require
'base64'
class
SessionsController
<
ApplicationController
include
ApiBackend
def
destroy_local
reset_user_session
if
SamlConfig
.
idp_sso_logout
...
...
app/controllers/signup_controller.rb
View file @
5ac149f0
class
SignupController
<
ApplicationController
include
ApiBackend
def
new
if
@token
# on by default
...
...
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