Commit 48853d3c authored by Birger Schacht's avatar Birger Schacht
Browse files

Start refactoring email forms

parent 9584f748
Pipeline #8214 canceled with stages
......@@ -38,11 +38,8 @@ class ResourcesController < ApplicationController
@resource_name = params[:resource_name]
if list_of_canonical_resources.include? @resource_name
data = {}
params.each do |name, v|
if name =~ /data_(.*)/
data[$1] = v
end
end
data['name'] = params[:localpart]
data['domain'] = params[:domain]
@res = api.resource_self_create(@resource_name, data)
update_account_properties
......
......@@ -11,14 +11,14 @@ class SignupController < ApplicationController
def create
(redirect_to '/signup' and return) unless @token
@email = params[:email]
@localpart = params[:localpart]
@new_pw = params[:new]
@enable_mail_crypt = true
@recovery_email = params[:recovery_email]
@domain = params[:domain]
@keep_recovery_token = params[:keep_recovery_token]
full_email = "#{@email}@#{@domain}"
full_email = "#{@localpart}@#{@domain}"
if EmailValidation::immerda_email_conform(full_email)
begin
res = api.valid_new_email?(full_email)
......
<div class="form-group">
<div class="input-group mb-1">
<%=
text_field_tag('localpart', "", class: 'form-control', required: true)
%>
<div class="input-group-prepend input-group-append">
<span class="input-group-text">@</span>
</div>
<%=
domains = ['immerda.ch'] if domains.blank?
if domains.length == 1
text_field_tag('domain', domains, class: 'form-control', readonly: true)
else
select_tag('domain', options_for_select(domains, 'immerda.ch'), class: 'form-control')
end
%>
</div>
<small id="emailHelp" class="form-text text-muted">
<%= t(:localpart_generate) %> <%= link_to t(:username), 'javascript:;', onclick: "randomUsername(update);"%>, <%= link_to "#{t(:words)} (en)", 'javascript:;', onclick: "randomProjectname(3, update);"%> or <%= link_to "#{t(:words)} (de)", 'javascript:;', onclick: "randomGermanProjectname(3, update);"%>
</small>
</div>
<script>
function update(name) {
var v = document.getElementById('localpart');
v.value = name;
}
</script>
......@@ -33,24 +33,7 @@ allowed = [q['max'].to_i - q['cur'].to_i, 0].max
<%= form_tag do %>
<%= hidden_field_tag 'resource_name', @resource_name %>
<% @resource_schema.each do |n,v| %>
<div class="form-group">
<%= label_tag n %>
<% if n == 'name' %>
<%= render 'random' %>
<% end %>
<%= case v
when Array
if v.length == 1
text_field_tag('data_'+n, v, class: 'form-control', readonly: true)
else
select_tag('data_'+n, options_for_select(v), class: 'form-control')
end
else
text_field_tag('data_'+n, "", class: 'form-control')
end %>
</div>
<% end %>
<%= render 'email', domains: @resource_schema['domain'] %>
<%= submit_tag t(:create), name: 'create', class: "btn btn-primary" %>
<% end %>
......
......@@ -10,13 +10,7 @@
<div class="row pt-3">
<%= form_tag("#{signup_path}/#{URI::escape(@token)}", method: "post") do %>
<div class="form-group">
<%= label_tag(:email, (t :email)) %>
<%= render 'random' %>
<%= text_field_tag(:email, '', value: @email || 'ig', autofill: 'off', class: "form-control") %>
@
<%= select_tag :domain, options_for_select(@domains.map{|d| [d,d]}, 'immerda.ch'), class: "form-control" %>
</div>
<%= render 'email', domains: @domains %>
<div class="form-group">
<%= label_tag(:new, (t :new_pw)) %>
......
......@@ -212,6 +212,7 @@ de:
mail_alias: "Email Alias"
mail_alias_description: "Eine zweite E-Mail Adresse, die auf dein bestehendes Postfach zeigt. Achtung, wir können nicht garantieren, dass dein Alias nie mit deiner Hauptadresse in Verbindung gebracht werden kann. Wenn du dies benötigst, bestelle bei uns ein separates zweites Konto."
mail_alias_edit_description: ""
localpart_generate: "Generiere zufällig ähnlich zu"
bills: Rechnungen
create_bill: Rechnung erstellen
......
......@@ -214,6 +214,7 @@ en:
mail_alias: "Email Alias"
mail_alias_description: "A second address pointing to your existing mailbox. We cannot guarantee that your alias can never be connected to your main address. If that is a requirement please ask us for a second mailbox."
mail_alias_edit_description: ""
localpart_generate: "Generate at random similar to"
bills: Bills
create_bill: Create invoice
......
Markdown is supported
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