Changes between Version 4 and Version 5 of login-service


Ignore:
Timestamp:
Aug 10, 2014, 12:49:14 PM (5 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • login-service

    v4 v5  
    2020
    2121{{{
     22#!/bin/bash
     23user="$1"
     24pass="$2"
     25app_id="$3"
     26out=$(curl -s "https://members.mayfirst.org:8080/check?user=$user&password=$pass&app_id=$3")
     27[ "$out" = "yes" ] && exit 0
     28exit 1
     29}}}
     30
     31{{{
    2232<?php
    2333
     
    3242}}}
    3343
     44While GET functions are easier to write, POST functions are less likely to log your password
     45(on the client side - logging is disabled on the server side).
     46
    3447{{{
    35 #!/bin/bash
    36 user="$1"
    37 pass="$2"
    38 app_id="$3"
    39 out=$(curl -s "https://members.mayfirst.org:8080/check?user=$user&password=$pass&app_id=$3")
    40 [ "$out" = "yes" ] && exit 0
    41 exit 1
     48<?php
     49
     50function authenticate_user($user, $password, $app_id) {
     51        $url = 'https://members.mayfirst.org:8080/check';
     52        $vars = 'user=' . $user . '&password=' . $password .
     53         '&app_id=' . $app_id;
     54
     55        $ch = curl_init( $url );
     56        curl_setopt( $ch, CURLOPT_POST, 1);
     57        curl_setopt( $ch, CURLOPT_POSTFIELDS, $vars);
     58        curl_setopt( $ch, CURLOPT_HEADER, 0);
     59        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
     60
     61        $response = curl_exec( $ch );
     62
     63        if($response == "yes") return TRUE;
     64        return FALSE;
     65}
    4266}}}
     67
     68