ispmail-on-rails 0.2.3 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01096e9085a7a63f8f1db334ca0ef2059bd388aa
4
- data.tar.gz: 4ad07c63b1bc0ec6c995208dd71287f2ee5c2f24
3
+ metadata.gz: 26ebc3f4f1d1f46091e87b3643171928c9a9d8b7
4
+ data.tar.gz: 502c2f66c1e307e921a6d504e9e6b8ff3ac74ba2
5
5
  SHA512:
6
- metadata.gz: 657df8f6e958a237069a090509e8671a5d46ac6bb75975607d41b086f09a3e2a23e65bb46cacb5c8669f68cbb7f567c235ca1f79876d98b58a37a9d3a8e1e31e
7
- data.tar.gz: 763d87bf8613b9e82218b9ef5086d0ef30cbe4cb97fca32fbe47e97b54b54e472c7aecf74b0054e758210367a66ab937293015f5263c6b4556c25b46680c84a3
6
+ metadata.gz: 98008acba0c599aacd6d3099f8b0f2d9b409d231af1e7d32a4b1b23ff57732b2670c248e7e136567a0ec75fc5a555e70f958fa07fb54afd030876d988aa97723
7
+ data.tar.gz: 8d3ac999527c9bd1e2325400e240dff30ef6dfefd8eeb1829a9016072abc084368b16a2c4b37e3383f6b4665d56d6f722a17e2c4c9ba0cb8f04064c97e41e3df
@@ -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, email: 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 <= 10
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>
@@ -6,7 +6,7 @@ class CreateVirtualDomains < ActiveRecord::Migration
6
6
 
7
7
  t.timestamps null: false
8
8
  end
9
- add_index :domains, :name, unique: true
9
+ add_index :virtual_domains, :name, unique: true
10
10
  rescue
11
11
  end
12
12
  end
@@ -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, :domains, on_delete: :cascade
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
- add_foreign_key :virtual_aliases, :domains, on_delete: :cascade
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
@@ -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", "domains", on_delete: :cascade
58
- add_foreign_key "virtual_users", "domains", on_delete: :cascade
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
@@ -1,7 +1,7 @@
1
1
  module Ispmail
2
2
  module On
3
3
  module Rails
4
- VERSION = "0.2.3"
4
+ VERSION = "0.3.0"
5
5
  end
6
6
  end
7
7
  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.2.3
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-28 00:00:00.000000000 Z
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: