Skip to content

Commit

Permalink
注册邮箱后缀可多个
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuiyong committed Sep 26, 2015
1 parent 54602a7 commit 37cd0fc
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 13 deletions.
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ Walle景愿是做一个web部署系统工具,[官网主页](http://www.huamans
* 开发者一键部署上线
* 快速回滚
* 查看上线日志
* 部署前准备任务(前置检查)
* 代码检出后处理任务(如vendor,环境配置)
* 同步到各目标机器后收尾任务(如重启)
* 执行sql构建(不要担心忘记测试环境sql同步)
* 线上文件指纹确认

依赖
---

* git
* web ui的运行环境php、nginx(apache)、mysql
* web ui的运行环境php5.4、nginx(apache)、mysql
* composer,安装walle、yii2
* ssh

Expand All @@ -29,14 +33,28 @@ Walle景愿是做一个web部署系统工具,[官网主页](http://www.huamans
git clone [email protected]:meolu/walle-web.git
cd walle-web
vi config/web.php # 设置mysql连接
composer install
composer install # 如果缺少bower-asset的话, 先安装:composer install global require "fxp/composer-asset-plugin:1.0.0-beta3"
./yii migrate/up # 导入数据库
```

快速开始
-------
* 首先[配置一个项目](https://github.com/meolu/walle-web/blob/master/yml-config.md)
* 提交上线任务
* 首先,配置邮箱,如果没有,好吧,先忽略,注册完手动修改user表的is_email_verified=1即可登录
```php
vi config/params.php
'mail-suffix' => '公司邮箱后缀.com'

vi config/web.php +20
# 配置mail smtp模块
'host' => 'ip or host', # smtp 发件地址
'username' => '[email protected]', # smtp 发件用户名
'password' => 'password', # smtp 发件人的密码
'port' => 25, # smtp 端口
'encryption' => 'tls', # smtp 协议
```
* 注册一个管理员身份用户,[配置一个项目](https://github.com/meolu/walle-web/blob/master/yml-config.md)
* 有公司邮箱的开发者注册,提交上线任务
* 管理员审核上线任务
* 发起上线


Expand Down
4 changes: 3 additions & 1 deletion config/params.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@
'user.emailConfirmationTokenExpire' => 43200, // 5 days

'config.dir' => '/deploy.yml/env',
'mail-suffix' => 'huamanshu.com',
'mail-suffix' => [
'公司邮箱后缀.com', // 限制只有公司同学可注册,可多个
]
];
10 changes: 5 additions & 5 deletions config/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
'useFileTransport' => false,
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'ip or host',
'username' => '[email protected]',
'password' => 'password',
'port' => 25,
'encryption' => 'tls',
'host' => 'ip or host', # smtp 发件地址
'username' => '[email protected]', # smtp 发件用户名
'password' => 'password', # smtp 发件人的密码
'port' => 25, # smtp 端口
'encryption' => 'tls', # smtp 协议
],
'messageConfig' => [
'charset' => 'UTF-8',
Expand Down
8 changes: 5 additions & 3 deletions models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,11 @@ public function rules()
}

public function validateEmail($attribute, $params) {
$mailSuffix = \Yii::$app->params['mail-suffix'];
if (!preg_match("/.*@{$mailSuffix}$/", $this->$attribute)) {
$this->addError($attribute, "我猜你丫是外星人,没有{$mailSuffix}邮箱不可注册:)");
// 支持多邮箱绑定
$mailSuffix = join('|@', \Yii::$app->params['mail-suffix']);
file_put_contents('/tmp/x', "/.*(@{$mailSuffix})$/", 8);
if (!preg_match("/.*(@{$mailSuffix})$/", $this->$attribute)) {
$this->addError($attribute, "没有" . join('', \Yii::$app->params['mail-suffix']) . "邮箱不可注册:)");
}
}
/**
Expand Down

0 comments on commit 37cd0fc

Please sign in to comment.