Beispiel #1
0
def login(auth=None):
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data.lower().strip()).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user, form.remember_me.data)
            return redirect(request.args.get('next') or url_for('main.index'))
        flash('Invalid username or password')
    elif auth == 'github':
        return github.authorize(callback=url_for('auth.authorized', _external=True, auth="github"))
    return render_template('auth/login.html', form=form)
Beispiel #2
0
def login(auth=None):
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(
            email=form.email.data.lower().strip()).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user, form.remember_me.data)
            return redirect(request.args.get('next') or url_for('main.index'))
        flash('Invalid username or password')
    elif auth == 'github':
        return github.authorize(
            callback=url_for('auth.authorized', _external=True, auth="github"))
    return render_template('auth/login.html', form=form)
Beispiel #3
0
def setup_webhook():
    pid = request.args.get("pid")
    if pid is None:
        abort(404)

    package = Package.query.get(pid)
    if package is None:
        abort(404)

    if not package.checkPerm(current_user, Permission.APPROVE_RELEASE):
        flash("Only trusted members can use webhooks", "danger")
        return redirect(package.getDetailsURL())

    gh_user, gh_repo = package.getGitHubFullName()
    if gh_user is None or gh_repo is None:
        flash("Unable to get Github full name from repo address", "danger")
        return redirect(package.getDetailsURL())

    if current_user.github_access_token is None:
        return github.authorize("write:repo_hook",
                                redirect_uri=abs_url_for(
                                    "github.callback_webhook", pid=pid))

    form = SetupWebhookForm(formdata=request.form)
    if form.validate_on_submit():
        token = APIToken()
        token.name = "GitHub Webhook for " + package.title
        token.owner = current_user
        token.access_token = randomString(32)
        token.package = package

        event = form.event.data
        if event != "push" and event != "create":
            abort(500)

        if handleMakeWebhook(gh_user, gh_repo, package,
                             current_user.github_access_token, event, token):
            flash("Successfully created webhook", "success")
            return redirect(package.getDetailsURL())
        else:
            return redirect(url_for("github.setup_webhook", pid=package.id))

    return render_template("github/setup_webhook.html",
                           form=form,
                           package=package)
Beispiel #4
0
def github_login():
    if not app.config.get("GITHUB_OAUTH_ENABLE"):
        return abort(400)
    return github.authorize(callback=url_for("authorized", _external=True))
Beispiel #5
0
def authorize():
    return github.authorize()
Beispiel #6
0
def login():
    session['github_action'] = 'login'
    return github.authorize(scope='user:email')
Beispiel #7
0
def register():
    session['github_action'] = 'register'
    return github.authorize(scope='user:email')
Beispiel #8
0
def github_auth():
    return github.authorize(
        callback=url_for('oauth.github_oauth_handler', _external=True),
        next=request.args.get('next') or request.referrer
    )
Beispiel #9
0
def login():
    return github.authorize(scope="user,repo,delete_repo")
 def get(self):
     return github.authorize(scope = 'user,public_repo')
Beispiel #11
0
def github_auth():
    return github.authorize(callback=url_for('oauth.github_oauth_handler',
                                             _external=True),
                            next=request.args.get('next') or request.referrer)
Beispiel #12
0
def login():
    return github.authorize()
Beispiel #13
0
 def authorize(self):
     return github.authorize(url_for('oauth_callback', provider=self.provider_name, _external=True), _external=True)
Beispiel #14
0
 def get(self):
     return github.authorize(scope='user,public_repo')
Beispiel #15
0
def authorize():
    """ Authorizes user with defined scope.
    """
    return github.authorize(scope=Config.scope)
Beispiel #16
0
def github_login():
    if not app.config.get('GITHUB_OAUTH_ENABLE'):
        return abort(400)
    return github.authorize(callback=url_for('authorized', _external=True))
Beispiel #17
0
def start():
	return github.authorize("", redirect_uri=abs_url_for("github.callback"))
Beispiel #18
0
def github_signin_page():
    return github.authorize("")