Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nishibayashi Takuji
committed
Jan 13, 2012
1 parent
ad727c2
commit d924901
Showing
7 changed files
with
120 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,33 @@ | ||
package Xpost::Model::User; | ||
use strict; | ||
use 5.014001; | ||
use warnings; | ||
use 5.010; | ||
package Xpost::Model::User { | ||
|
||
use parent qw/Xpost::Model/; | ||
use String::Random; | ||
|
||
use parent qw/Xpost::Model/; | ||
|
||
our $UNATH_PREFIX = '__UNAUTH__'; | ||
|
||
sub register_email { | ||
state $validator = Data::Validator->new( | ||
email => {isa => 'Str'} | ||
)->with(qw/Method/); | ||
my ($class, $args) = $validator->validate(@_); | ||
my $random_uname = $class->create_initial_username; | ||
$class->fast_insert({%$args, username => $UNATH_PREFIX.$random_uname}); | ||
return $random_uname; | ||
} | ||
|
||
sub create_initial_username { | ||
my $class = shift; | ||
state $rand = String::Random->new; | ||
my $random_uname = $rand->randregex('[a-zA-Z0-9]{16}'); | ||
my $full_random_uname = $UNATH_PREFIX . $random_uname; | ||
if ($class->db->count('user' => 'id', {username_hash => $class->make_hash($full_random_uname), username => $full_random_uname})) { | ||
$random_uname = $class->create_initial_username; | ||
} | ||
return $random_uname; | ||
} | ||
|
||
} | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use 5.014001; | ||
use warnings; | ||
package Xpost::Validator::Register { | ||
use parent qw/Xpost::Validator/; | ||
|
||
use Xpost::Model::User; | ||
|
||
sub email { | ||
my $self = shift; | ||
$self->check( | ||
email => ['NOT_NULL', 'EMAIL_LOOSE'], | ||
); | ||
return if $self->has_error; | ||
|
||
if(Xpost::Model::User->count('id' => {email => $self->query->param('email')})) { | ||
$self->set_error(email => 'UNIQUE'); | ||
} | ||
} | ||
} | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,18 @@ | ||
:cascade layout | ||
|
||
:around content -> { | ||
<h1>2011年マビノギ課金ログ</h1> | ||
<p>課金件数:<: $cnt :>件</p> | ||
<p>合計課金額:¥<: $sum :></p> | ||
<h1>Xpost.jp <small>Simple twitter clone</small></h1> | ||
<p>More simple. More fun.</p> | ||
|
||
<h2>今すぐ登録</h2> | ||
<p>登録にはメールアドレスが必要です。</p> | ||
<p>携帯メールでも可ですがPCメールをオススメします。</p> | ||
<p>登録されたメールアドレスはXpostからの通知、サポートなどサービスに必要な場合にのみ利用し、Senchan.jpの運営する他サービス含む他の目的には使用しません。</p> | ||
<form action="/register/email" method="post" class="form-stacked"> | ||
:input({type => 'text', name => 'email', label => 'Email', class => 'span12'}) | ||
<div class="actions"> | ||
<button type="submit" class="btn primary">登録</button> | ||
</div> | ||
</form> | ||
:} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
:cascade layout | ||
|
||
:around content -> { | ||
<h1>メールアドレス登録完了!</h1> | ||
<p>入力したメールアドレスにメールを送信しました。メールに書かれているURLをクリックして登録を続けてください。</p> | ||
:} |