# Copyright (c) 2006 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: EmailVerifyForm.pm,v 2.3 2011/05/11 21:13:44 schellj Exp $ package Bivio::Biz::Model::EmailVerifyForm; use strict; use Bivio::Base 'Biz.FormModel'; our($VERSION) = sprintf('%d.%02d', q$Revision: 2.3 $ =~ /\d+/g); my($_ULF) = b_use('Model.UserLoginForm'); my($_A) = b_use('Biz.Action'); my($_EV) = b_use('Model.EmailVerify'); sub execute_empty { my($self) = @_; my($req) = $self->get_request; my($q) = $req->unsafe_get('query'); if ($q && $q->{$_EV->VERIFY_KEY}) { $req->put(query => {}); my($ev) = $self->new_other('EmailVerify'); if ($ev->check_key_and_update($q)) { $_A->get_instance('Acknowledgement')->save_label( email_verified => $req, ); $self->internal_update_email($ev->get('email')); return { task_id => 'ok_task', no_context => 1, query => $self->req('query'), }; } $self->internal_put_error('Email.email' => 'EMAIL_VERIFY_KEY'); } $self->internal_put_field('Email.email' => $q && $q->{$_EV->EMAIL_KEY} ? $q->{$_EV->EMAIL_KEY} : $self->internal_get_email); return; } sub execute_ok { my($self) = @_; $self->internal_put_field( uri => $self->new_other('EmailVerify') ->uri_with_new_key($self->get('Email.email'))); $self->put_on_request(1); return; } sub internal_get_email { return shift->new_other('Email')->load->get('email'); } sub internal_initialize { my($self) = @_; return $self->merge_initialize_info($self->SUPER::internal_initialize, { version => 1, visible => [ 'Email.email', ], other => [ { name => 'uri', type => 'HTTPURI', constraint => 'NONE', }, ], auth_id => 'Email.realm_id', }); } sub internal_update_email { my($self, $email) = @_; $self->new_other('Email')->load->update({ email => $email, }); return; } 1;