Repository: airavata-php-gateway
Updated Branches:
  refs/heads/master 1fd4df46a -> 667d07161


working with captcha


Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/667d0716
Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/667d0716
Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/667d0716

Branch: refs/heads/master
Commit: 667d07161ac08eaac55595edc664d89226d10b62
Parents: 1fd4df4
Author: scnakandala <[email protected]>
Authored: Wed Feb 10 14:14:39 2016 -0500
Committer: scnakandala <[email protected]>
Committed: Wed Feb 10 14:14:39 2016 -0500

----------------------------------------------------------------------
 app/controllers/AccountController.php    | 28 +++++++++++++++------
 app/routes.php                           |  2 ++
 app/views/account/verify-human.blade.php | 36 +++++++++++++++++++++++++++
 3 files changed, 59 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/667d0716/app/controllers/AccountController.php
----------------------------------------------------------------------
diff --git a/app/controllers/AccountController.php 
b/app/controllers/AccountController.php
index f0131eb..b43bf29 100755
--- a/app/controllers/AccountController.php
+++ b/app/controllers/AccountController.php
@@ -133,7 +133,6 @@ class AccountController extends BaseController
             Session::put('oauth-refresh-code',$refreshToken);
             Session::put('oauth-expiration-time',$expirationTime);
             Session::put("user-profile", $userProfile);
-            Session::put('username', "Eroma2015");
             if (in_array(Config::get('pga_config.wsis')['admin-role-name'], 
$userRoles)) {
                 Session::put("admin", true);
             }
@@ -307,15 +306,30 @@ class AccountController extends BaseController
             return View::make("home");
         }else{
             try{
-                $result = WSIS::confirmUserRegistration($username, 
$confirmation, Config::get('pga_config.wsis')['tenant-domain']);
-                if($result){
-                    $this->sendAccountCreationNotification2Admin($username);
-                    return Redirect::to("login");
+                if(Input::has("userAnswer")){
+                    $result = 
WSIS::confirmUserRegistration(Input::get("userAnswer"),Input::get("imagePath"),
+                        Input::get("secretKey"), $username, $confirmation, 
Config::get('pga_config.wsis')['tenant-domain']);
+                    if($result->verified){
+                        
$this->sendAccountCreationNotification2Admin($username);
+                        return Redirect::to("login");
+                    }else if(!$result->verified && preg_match('/Error while 
validating captcha for user/',$result->error) ){
+                        CommonUtilities::print_error_message("Captcha 
Verification failed!");
+                        $capatcha = WSIS::getCapatcha()->return;
+                        return View::make("account/verify-human", 
array("username"=>$username,"code"=>$confirmation,
+                            "imagePath"=>$capatcha->imagePath, 
"secretKey"=>$capatcha->secretKey,
+                            "imageUrl"=> 
Config::get("pga_config.wsis")["service-url"] . $capatcha->imagePath));
+                    }else{
+                        CommonUtilities::print_error_message("Account 
confirmation failed!");
+                        return View::make("home");
+                    }
                 }else{
-                    CommonUtilities::print_error_message("Account confirmation 
failed!");
-                    return View::make("home");
+                    $capatcha = WSIS::getCapatcha()->return;
+                    return View::make("account/verify-human", 
array("username"=>$username,"code"=>$confirmation,
+                        "imagePath"=>$capatcha->imagePath, 
"secretKey"=>$capatcha->secretKey,
+                        "imageUrl"=> 
Config::get("pga_config.wsis")["service-url"] . $capatcha->imagePath));
                 }
             }catch (Exception $e){
+                var_dump($e);exit;
                 CommonUtilities::print_error_message("Account confirmation 
failed!");
                 return View::make("home");
             }

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/667d0716/app/routes.php
----------------------------------------------------------------------
diff --git a/app/routes.php b/app/routes.php
index 84bce56..2d0468e 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -36,6 +36,8 @@ Route::post("forgot-password", 
"AccountController@forgotPasswordSubmit");
 
 Route::get("confirm-user-registration", 
"AccountController@confirmAccountCreation");
 
+Route::post("confirm-user-registration", 
"AccountController@confirmAccountCreation");
+
 Route::get("setUserTimezone", function () {
     Session::set("user_timezone", Input::get("timezone"));
 });

http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/667d0716/app/views/account/verify-human.blade.php
----------------------------------------------------------------------
diff --git a/app/views/account/verify-human.blade.php 
b/app/views/account/verify-human.blade.php
new file mode 100644
index 0000000..7c9ce1f
--- /dev/null
+++ b/app/views/account/verify-human.blade.php
@@ -0,0 +1,36 @@
+@extends('layout.basic')
+
+@section('page-header')
+@parent
+@stop
+
+@section('content')
+
+<div class="col-md-offset-3 col-md-6">
+
+    <h3>Verify you are human</h3>
+    @if ($errors->has())
+    @foreach ($errors->all() as $error)
+    {{ CommonUtilities::print_error_message($error) }}
+    @endforeach
+    @endif
+    <form role="form" method="POST">
+        <div class="form-group form-horizontal">
+            <img src="{{$imageUrl}}"/>
+            <hr>
+            <div>
+                <input name="confirmationCode" type="hidden" value="{{$code}}" 
class="form-control"/>
+                <input name="username" type="hidden" value="{{$username}}" 
class="form-control"/>
+                <input name="imagePath" type="hidden" value="{{$imagePath}}" 
class="form-control"/>
+                <input name="secretKey" type="hidden" value="{{$secretKey}}" 
class="form-control"/>
+                <input class="form-control" id="userAnswer" name="userAnswer" 
required="required"/></div>
+            </div>
+            <div class="form-group btn-toolbar">
+                <div class="btn-group">
+                    <input type="submit" class="form-control btn btn-primary" 
value="Submit"/>
+                </div>
+            </div>
+
+        </div>
+    </form>
+@stop
\ No newline at end of file

Reply via email to