root/websites/mobilecat/trunk/lib/MobileCat/Controller/Signup.pm

Revision 16950, 1.4 kB (checked in by tomi-ru, 20 months ago)

マイページ系

Line 
1package MobileCat::Controller::Signup;
2use strict;
3use warnings;
4use base 'Catalyst::Controller';
5
6sub index :Private {
7    my ($self, $c) = @_;
8    $c->view('TT')->template('signup/index.tt');
9}
10
11sub entry :Local {
12    my ($self, $c) = @_;
13   
14    if ($c->forward('/auth/authenticate_mobileid')) {
15        $c->stash->{error} = 'already exists';
16        return;
17    }
18   
19    if (not $c->forward('/auth/confirm_mobile')) {
20        $c->stash->{error} = $c->stash->{auth_error} || 'unknown';
21        return;
22    }
23   
24    $c->forward('create');
25}
26
27sub create :Private {
28    my ($self, $c) = @_;
29   
30    my $user = $c->model('Users')->create({
31        username  => undef,
32        mobile_id => $c->req->mobile_agent->user_id,
33    });
34   
35    $c->stash->{ticket} = $c->model('Tickets')->create({
36        action  => 'signup',
37        user_id => $user->id,
38    });
39}
40
41sub welcome :Private {
42    my ($self, $c) = @_;
43   
44    my $user = $c->stash->{ticket}->user;
45    $c->req->param(username => $user->mobile_id);
46    $c->req->param(email    => $c->req->param('sender'));
47    $c->form(
48        username => [ 'NOT_BLANK' ],
49        email    => [ 'NOT_BLANK', 'EMAIL_MOBILE_JP' ],
50    );
51   
52    if ($c->form->has_error) {
53        return;
54    }
55    if ($user->enable($c->form->valid)) {
56        $c->view('Email')->send('mail/welcome.tt', {
57            to => $user->email,
58        });
59    } else {
60        $c->log->error('user enable error. user_id:'. $user->id);
61    }
62}
63
641;
Note: See TracBrowser for help on using the browser.