Пример #1
0
def editgroups():
    
    if request.method == 'POST':
        username = request.args.get('user') 
        org_domain = request.args.get('org_domain')
        gAPI = google_api.gAPI(org_domain, username, "")
        user_chosen = json.loads(request.form['user_chosen'])
        domain_chosen = json.loads(request.form['domain_chosen'])
        relationTable = gAPI.setGroupRelation()
        
        if request.form['submit_state2'] == 'true':
            gAPI.addToGroup(relationTable[request.form['submit_value2']])
        
        if request.form['submit_state1'] == 'true':
            gAPI.removeFromGroup(relationTable[request.form['submit_value1']])
        
        return render_template('editgroups.html', username=username, org_domain=org_domain, userGroups=user_chosen, domainGroups=domain_chosen)
    
    if request.method == 'GET':
        username = request.args.get('user')
        org_domain = request.args.get('org_domain')
        gAPI = google_api.gAPI(org_domain, username, "")
        domainGroups=gAPI.retrieveDomainGroupNames()
        userGroups=gAPI.retriveUserGroupNames()
               
        return render_template('editgroups.html', username=username, org_domain=org_domain, userGroups=userGroups, domainGroups=domainGroups)
Пример #2
0
def user_list_display():
    org_domain = request.form['org_domain']
    gAPI = google_api.gAPI(org_domain, None, "")
    domain_users=gAPI.retrieve_domain_usernames()
    given_names=gAPI.retrieve_domain_givennames()
    family_names=gAPI.retrieve_domain_familynames()
    return render_template('user_list_display.html', domain_users=domain_users, given_names=given_names, family_names=family_names, org_domain=org_domain )
Пример #3
0
def unsuspend_user():
    user = request.args.get('user')
    org_domain = request.args.get('org_domain')
    gAPI = google_api.gAPI(org_domain, user, "")
    gAPI.unsuspend_user()
    message= "unsuspended"
    message_two = "If you would like to undo this action, simply navigate back to the list of users in the domain group and click the suspend button, again."
    return render_template('actionconfirm.html', message=message, message_two=message_two, user=user, org_domain=org_domain)
Пример #4
0
def delete_user():
    user = request.args.get('user')
    org_domain = request.args.get('org_domain')
    gAPI = google_api.gAPI(org_domain, user, "")
    gAPI.delete_user()
    message= "deleted"
    message_two = "This action CAN NOT be undone. The user has been erased from the system. If you would like to create a new account please click users at the top of the screen and follow the instructions"
    return render_template('actionconfirm.html', message=message, message_two=message_two, user=user, org_domain=org_domain)
Пример #5
0
def editusers():
    form = EditUsersForm()
    
    user = request.args.get('user')
    org_domain = request.args.get('org_domain')
    
    if request.method == "POST":
            user = request.args.get('user')
            org_domain = request.args.get('org_domain')
            gAPI = google_api.gAPI(org_domain, user, "")
            
            if form.password_alpha.data == "":
                pass
            else:
                if form.password_alpha.data != form.password_beta.data:
                    flash('Passwords must match.')
                    return redirect(url_for('editusers', user=form.username.data, org_domain=org_domain))
                else:
                    gAPI.update_user_password(form.password_alpha.data)
        
            if request.form.get("clear_nicknames") == "clear":
                gAPI.delete_all_user_nicknames()
            else:
                for i in range(1, 7):
                    if nickname_len(request.form.get('nickname' + str(i))):
                        pass
                    else:
                        gAPI.create_nickname(request.form.get('nickname' + str(i)))
                
            gAPI.update_user_givenname(form.givenname.data)
            gAPI.update_user_familyname(form.familyname.data)
            gAPI.update_user_username(form.username.data)
            return redirect(url_for('editusers', user=form.username.data, org_domain=org_domain))

    if request.method == "GET":
        gAPI = google_api.gAPI(org_domain, user, "")
        return render_template('editusers.html', username=user, org_domain=org_domain,form=form, givenname=gAPI.get_firstname(), familyname=gAPI.get_lastname(), nicknames=gAPI.retrieve_nicknames())     
Пример #6
0
def new_account_setup():
    form = NewUserForm()
    
    if request.method == 'POST':
        if form.validate() == False:
            flash('All fields are required.')
            return render_template('new_account_setup.html', domains_list=settings.list_of_local_domains, domains_tag=settings.local_domain_paths, form=form)
        else:
            gAPI = google_api.gAPI(request.form.get('org_domain'), form.username.data, form.password_alpha.data)
            gAPI.create_new_user(form.givenname.data, form.familyname.data)
            if request.form.get('ADcheckbox') == 'on':
                LDAP.addUser(str(form.username.data), str(form.givenname.data), str(form.familyname.data), str(form.email.data), str(form.password_alpha.data), str(request.form.get('org_name')))
                if request.form.get('hiddenGroupsList') == '':
                    pass
                else:
                    for group in eval(request.form.get('hiddenGroupsList')):
                        group_dn = group[0]
                        user_dn = 'CN=' + str(form.givenname.data) + ' ' + str(form.familyname.data) + ',OU=' + str(request.form.get('org_name')) + ',' + settings.local_DC
                        LDAP.addUsertoGroups(group_dn, user_dn)
            else:
                pass
            return redirect(url_for('home'))
    elif request.method == 'GET':
        return render_template('new_account_setup.html', domains_list=settings.list_of_local_domains, domains_tag=settings.local_domain_paths, form=form, ADorg_list=LDAP.retrieveADGroups())
Пример #7
0
def _initFromHTML(org_domain, username, password):
    gAPI = google_api.gAPI(org_domain, username, password)
    return gAPI