Changes between Version 9 and Version 10 of login-service


Ignore:
Timestamp:
Jun 1, 2016, 11:30:45 AM (4 years ago)
Author:
Jamie McClelland
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • login-service

    v9 v10  
    6060#!/usr/bin/python
    6161
    62 from mayfirstAuth import auth
     62from mayfirstAuth import check, user
    6363
    6464username = 'YOUR-USER-NAME'
     
    6666appid = 'YOUR-APP-ID'
    6767
    68 check = auth(username, password, appid)
     68check = check(username, password, appid)
     69user = user(username, appid)
    6970
    7071if check == "0":
    7172    print 'Login success'
    72 else
     73else:
    7374    print 'Login failure'
     75
     76if user == "0":
     77    print 'User exists'
     78else:
     79    print 'User does not exist'
    7480}}}
    7581
     
    7783'''Source:'''
    7884
     85Save this file as mayfirstAuth.py in /usr/local/lib/python2.7/dist-packages
    7986{{{
    8087#!/usr/bin/python
     
    8592url = 'https://id.mayfirst.org:8080/'
    8693
    87 
    88 def auth(username, password, appid):
     94def check(username, password, appid):
    8995    values = {'user' : username,
    9096              'password' : password,
    9197              'app_id' : appid}
    92    
     98
    9399    req = requests.post(url + "check", data=values)
    94100    is_valid_user = req.text
     
    98104    return "1"
    99105
    100 def user(username):
     106def user(username, appid):
    101107    values = {'user' : username,
    102108              'app_id' : appid}
    103    
    104     req = requests.post(url + user, data=values)
     109
     110    req = requests.post(url + "user", data=values)
    105111    is_valid_user = req.text
    106112
     
    108114        return "0"
    109115    return "1"
    110 
    111116}}}
    112117
     
    116121<?php
    117122
     123// Fixme - only supports check not user.
    118124function authenticate_user($user, $password, $app_id) {
    119125  $url = 'https://id.mayfirst.org:8080/check?user=' . urlencode($user) .
     
    132138<?php
    133139
     140// Fixme - only supports check not user.
    134141function authenticate_user($user, $password, $app_id) {
    135142        $url = 'https://id.mayfirst.org:8080/check';