~edwargix/git.sr.ht

a8bb8e568e49f2c617a7bdd85872db022f73dda6 — Drew DeVault 8 years ago 1a30d7f
Clean up some auth stuff

Turns out previously logging in twice would make you an entirely new
account. Lame.
4 files changed, 8 insertions(+), 3 deletions(-)

M git/blueprints/auth.py
M git/blueprints/manage.py
M git/blueprints/public.py
M templates/user.html
M git/blueprints/auth.py => git/blueprints/auth.py +4 -2
@@ 1,5 1,6 @@
from flask import Blueprint, request, render_template, redirect
from flask_login import login_user, logout_user
from sqlalchemy import or_
from srht.config import cfg
from srht.flask import DATE_FORMAT
from srht.database import db


@@ 53,11 54,12 @@ def oauth_callback():
        return render_template("oauth-error.html",
            details="Error occured retrieving account info. Try again.")
    
    user = User.query.filter(User.oauth_token == token).first()
    json = r.json()
    user = User.query.filter(or_(User.oauth_token == token,
        User.username == json["username"])).first()
    if not user:
        user = User()
        db.session.add(user)
    json = r.json()
    user.username = json.get("username")
    user.email = json.get("email")
    user.paid = json.get("paid")

M git/blueprints/manage.py => git/blueprints/manage.py +1 -0
@@ 54,6 54,7 @@ def create():

    path = os.path.join(repos_path, "~" + current_user.username)

    subprocess.run(["mkdir", "-p", path])
    subprocess.run(["git", "init", "--bare", repo_name], cwd=path)
    subprocess.run(["ln", "-s", repo_name, repo_name + ".git"], cwd=path)


M git/blueprints/public.py => git/blueprints/public.py +1 -1
@@ 1,4 1,4 @@
from flask import Blueprint, Response, request, render_template
from flask import Blueprint, Response, request, render_template, abort
import requests
from srht.config import cfg
from git.types import User, Repository, RepoVisibility

M templates/user.html => templates/user.html +2 -0
@@ 6,6 6,7 @@
      <h2>
        ~{{ user.username }}
      </h2>
      {% if profile %}
      {% if profile.get("location") %}
      <p>{{profile["location"]}}</p>
      {% endif %}


@@ 19,6 20,7 @@
      {% if profile.get("bio") %}
      <p>{{profile["bio"]}}</p>
      {% endif %}
      {% endif %}
    </section>
    <section class="col-md-8">
      {% if len(repos) == 0 %}