ispmail-on-rails 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/virtual_alias.rb +5 -1
- data/app/validators/alias_validator.rb +11 -0
- data/app/validators/password_validator.rb +1 -1
- data/app/views/application/_heading.html.erb +1 -1
- data/db/migrate/20160321130230_create_virtual_domains.rb +1 -1
- data/db/migrate/20160321130250_create_virtual_users.rb +1 -1
- data/db/migrate/20160321130353_create_virtual_aliases.rb +2 -1
- data/db/schema.rb +10 -10
- data/lib/ispmail/on/rails/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ebc3f4f1d1f46091e87b3643171928c9a9d8b7
|
4
|
+
data.tar.gz: 502c2f66c1e307e921a6d504e9e6b8ff3ac74ba2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98008acba0c599aacd6d3099f8b0f2d9b409d231af1e7d32a4b1b23ff57732b2670c248e7e136567a0ec75fc5a555e70f958fa07fb54afd030876d988aa97723
|
7
|
+
data.tar.gz: 8d3ac999527c9bd1e2325400e240dff30ef6dfefd8eeb1829a9016072abc084368b16a2c4b37e3383f6b4665d56d6f722a17e2c4c9ba0cb8f04064c97e41e3df
|
data/app/models/virtual_alias.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class VirtualAlias < ActiveRecord::Base
|
2
2
|
validates :source, presence: true, domain_name: true, email: true
|
3
|
-
validates :destination, presence: true,
|
3
|
+
validates :destination, presence: true, alias: true, uniqueness: true
|
4
4
|
validates :domain_id, presence: true
|
5
5
|
|
6
6
|
belongs_to :virtual_domain, foreign_key: :domain_id
|
@@ -8,9 +8,13 @@ class VirtualAlias < ActiveRecord::Base
|
|
8
8
|
before_validation :complete_emails
|
9
9
|
|
10
10
|
private
|
11
|
+
|
12
|
+
# Complete email addresses with the domain, if only user name is given
|
13
|
+
# Clean up destination list to pass the AliasValidator
|
11
14
|
def complete_emails
|
12
15
|
self.source += "@#{virtual_domain.name}" unless source =~ /@/
|
13
16
|
self.destination += "@#{virtual_domain.name}" unless destination =~ /@/
|
17
|
+
self.destination = destination.split(/,| /).select {|ds| !ds.empty? }.map(&:strip).join(", ")
|
14
18
|
end
|
15
19
|
|
16
20
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Validates that a string contains only valid email addresses, separated by comma
|
2
|
+
class AliasValidator < EmailValidator
|
3
|
+
def validate_each(record, attribute, value)
|
4
|
+
destinations = value.split(",")
|
5
|
+
unless destinations.map {|destination|
|
6
|
+
self.class.valid? destination.strip
|
7
|
+
}.all?
|
8
|
+
record.errors[attribute] << (options[:message] || "is not a valid list of email addresses")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Validates the attribute's value is an acceptable password
|
2
2
|
class PasswordValidator < ActiveModel::EachValidator
|
3
3
|
def validate_each(record, attribute, value)
|
4
|
-
if record.password_changing? && value.to_s.size
|
4
|
+
if record.password_changing? && value.to_s.size < 10
|
5
5
|
record.errors[attribute] << (options[:message] || "must be minimum 10 characters long")
|
6
6
|
elsif record.password.blank? && !record.password_changing?
|
7
7
|
record.errors[attribute] << (options[:message] || "must be set")
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<!-- domain-heading from application/_heading.html.erb -->
|
2
2
|
<div class="row domain-heading">
|
3
3
|
<div class="small-6 columns">
|
4
|
-
<h1>Virtual users for <%= @domain.name %></h1>
|
4
|
+
<h1>Virtual <%= @virtual_user.nil? ? "aliases" : "users" %> for <%= @domain.name %></h1>
|
5
5
|
</div>
|
6
6
|
<div class="small-6 columns">
|
7
7
|
<p>
|
@@ -9,7 +9,7 @@ class CreateVirtualUsers < ActiveRecord::Migration
|
|
9
9
|
t.timestamps null: false
|
10
10
|
end
|
11
11
|
add_index :virtual_users, :email, unique: true
|
12
|
-
add_foreign_key :virtual_users, :
|
12
|
+
add_foreign_key :virtual_users, :virtual_domains, column: :domain_id, on_delete: :cascade
|
13
13
|
rescue
|
14
14
|
end
|
15
15
|
end
|
@@ -8,7 +8,8 @@ class CreateVirtualAliases < ActiveRecord::Migration
|
|
8
8
|
|
9
9
|
t.timestamps null: false
|
10
10
|
end
|
11
|
-
|
11
|
+
add_index :virtual_aliases, :destination, unique: true
|
12
|
+
add_foreign_key :virtual_aliases, :virtual_domains, column: :domain_id, on_delete: :cascade
|
12
13
|
rescue
|
13
14
|
end
|
14
15
|
end
|
data/db/schema.rb
CHANGED
@@ -13,14 +13,6 @@
|
|
13
13
|
|
14
14
|
ActiveRecord::Schema.define(version: 20160321133546) do
|
15
15
|
|
16
|
-
create_table "domains", force: :cascade do |t|
|
17
|
-
t.string "name", limit: 255, null: false
|
18
|
-
t.datetime "created_at", null: false
|
19
|
-
t.datetime "updated_at", null: false
|
20
|
-
end
|
21
|
-
|
22
|
-
add_index "domains", ["name"], name: "index_domains_on_name", unique: true, using: :btree
|
23
|
-
|
24
16
|
create_table "users", force: :cascade do |t|
|
25
17
|
t.datetime "created_at", null: false
|
26
18
|
t.datetime "updated_at", null: false
|
@@ -43,6 +35,14 @@ ActiveRecord::Schema.define(version: 20160321133546) do
|
|
43
35
|
|
44
36
|
add_index "virtual_aliases", ["domain_id"], name: "index_virtual_aliases_on_domain_id", using: :btree
|
45
37
|
|
38
|
+
create_table "virtual_domains", force: :cascade do |t|
|
39
|
+
t.string "name", limit: 255, null: false
|
40
|
+
t.datetime "created_at", null: false
|
41
|
+
t.datetime "updated_at", null: false
|
42
|
+
end
|
43
|
+
|
44
|
+
add_index "virtual_domains", ["name"], name: "index_virtual_domains_on_name", unique: true, using: :btree
|
45
|
+
|
46
46
|
create_table "virtual_users", force: :cascade do |t|
|
47
47
|
t.integer "domain_id", limit: 4, null: false
|
48
48
|
t.string "password", limit: 255, null: false
|
@@ -54,6 +54,6 @@ ActiveRecord::Schema.define(version: 20160321133546) do
|
|
54
54
|
add_index "virtual_users", ["domain_id"], name: "index_virtual_users_on_domain_id", using: :btree
|
55
55
|
add_index "virtual_users", ["email"], name: "index_virtual_users_on_email", unique: true, using: :btree
|
56
56
|
|
57
|
-
add_foreign_key "virtual_aliases", "
|
58
|
-
add_foreign_key "virtual_users", "
|
57
|
+
add_foreign_key "virtual_aliases", "virtual_domains", column: "domain_id", on_delete: :cascade
|
58
|
+
add_foreign_key "virtual_users", "virtual_domains", column: "domain_id", on_delete: :cascade
|
59
59
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ispmail-on-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Runar Ingebrigtsen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- app/models/virtual_alias.rb
|
100
100
|
- app/models/virtual_domain.rb
|
101
101
|
- app/models/virtual_user.rb
|
102
|
+
- app/validators/alias_validator.rb
|
102
103
|
- app/validators/domain_name_validator.rb
|
103
104
|
- app/validators/password_validator.rb
|
104
105
|
- app/views/api/virtual_aliases/index.json.jbuilder
|
@@ -195,3 +196,4 @@ signing_key:
|
|
195
196
|
specification_version: 4
|
196
197
|
summary: Rails app to manage ISPMAIL
|
197
198
|
test_files: []
|
199
|
+
has_rdoc:
|