Beispiel #1
0
def create_account(db_session, email, password):
    provider = provider_from_address(email)
    auth_handler = handler_from_email(email)
    # Special-case Gmail and Outlook, because we need to provide an oauth token
    # and not merely a password.
    if provider == 'gmail':
        token = google_auth(email, password)
        account = create_gmail_account(db_session, email, token, False)
    elif provider == 'outlook':
        token = outlook_auth(email, password)
        account = create_outlook_account(db_session, email, token, False)
    else:
        response = {"email": email, "password": password}
        account = auth_handler.create_account(db_session, email, response)

    auth_handler.verify_account(account)

    db_session.add(account)
    db_session.commit()
Beispiel #2
0
def create_account(db_session, email, password):
    provider = provider_from_address(email)
    auth_handler = handler_from_email(email)
    # Special-case Gmail and Outlook, because we need to provide an oauth token
    # and not merely a password.
    if provider == 'gmail':
        token = google_auth(email, password)
        account = create_gmail_account(db_session, email, token, False)
    elif provider == 'outlook':
        token = outlook_auth(email, password)
        account = create_outlook_account(db_session, email, token, False)
    else:
        response = {"email": email, "password": password}
        account = auth_handler.create_account(db_session, email, response)

    auth_handler.verify_account(account)

    db_session.add(account)
    db_session.commit()
    return account
Beispiel #3
0
def create_account(db_session, email, password):
    provider = provider_from_address(email)
    auth_handler = handler_from_provider(provider)
    # Special-case Gmail and Outlook, because we need to provide an oauth token
    # and not merely a password.
    response = {'email': email}
    if provider == 'gmail':
        code = google_auth(email, password)
        response = auth_handler._get_authenticated_user(code)
    elif provider == 'outlook':
        code = outlook_auth(email, password)
        response = auth_handler._get_authenticated_user(code)
    else:
        response = {"email": email, "password": password}

    account = auth_handler.create_account(db_session, email, response)
    auth_handler.verify_account(account)

    db_session.add(account)
    db_session.commit()
    return account
Beispiel #4
0
def create_account(db_session, email, password):
    provider = provider_from_address(email)
    auth_handler = handler_from_provider(provider)
    # Special-case Gmail and Outlook, because we need to provide an oauth token
    # and not merely a password.
    response = {"email": email}
    if provider == "gmail":
        code = google_auth(email, password)
        response = auth_handler._get_authenticated_user(code)
    elif provider == "outlook":
        code = outlook_auth(email, password)
        response = auth_handler._get_authenticated_user(code)
    else:
        response = {"email": email, "password": password}

    account = auth_handler.create_account(email, response)
    auth_handler.verify_account(account)
    account.throttled = False
    account.sync_host = platform.node()
    account.desired_sync_host = platform.node()
    db_session.add(account)
    db_session.commit()
    return account