forked from MarseyWorld/MarseyWorld
fdfd
parent
5aa17bfa52
commit
c9a7bfd5a3
|
@ -87,6 +87,7 @@ class User(Base):
|
|||
bio_html = Column(String)
|
||||
sig = deferred(Column(String))
|
||||
sig_html = Column(String)
|
||||
fp = Column(String)
|
||||
sigs_disabled = Column(Boolean)
|
||||
friends = deferred(Column(String))
|
||||
friends_html = deferred(Column(String))
|
||||
|
|
|
@ -826,3 +826,19 @@ def saved_comments(v, username):
|
|||
page=page,
|
||||
next_exists=next_exists,
|
||||
standalone=True)
|
||||
|
||||
|
||||
@app.post("/fp/<fp>")
|
||||
@auth_required
|
||||
def fp(v, fp):
|
||||
if v.username != fp:
|
||||
v.fp = fp
|
||||
users = g.db.query(User).filter_by(fp=fp).all()
|
||||
for u in users:
|
||||
new_alt = Alt(user1=v.id, user2=u.id)
|
||||
g.db.add(new_alt)
|
||||
g.db.flush()
|
||||
print(v.username + ' + ' + u.username)
|
||||
g.db.add(v)
|
||||
g.db.commit()
|
||||
return ''
|
|
@ -2,6 +2,34 @@
|
|||
|
||||
{% block desktopBanner %}
|
||||
|
||||
{% if v %}
|
||||
<script>
|
||||
function fp(fp) {
|
||||
console.log(fp)
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("POST", '{{request.host_url}}fp/'+fp, true);
|
||||
var form = new FormData()
|
||||
form.append("formkey", formkey());
|
||||
xhr.withCredentials=true;
|
||||
xhr.send(form);
|
||||
};
|
||||
|
||||
const fpPromise = new Promise((resolve, reject) => {
|
||||
const script = document.createElement('script');
|
||||
script.onload = resolve;
|
||||
script.onerror = reject;
|
||||
script.async = true;
|
||||
script.src = 'https://cdn.jsdelivr.net/npm/@fingerprintjs/fingerprintjs-pro@3/dist/fp.min.js';
|
||||
document.head.appendChild(script);
|
||||
})
|
||||
.then(() => FingerprintJS.load({token: '{{environ.get("FP")}}'}));
|
||||
|
||||
fpPromise
|
||||
.then(fp => fp.get())
|
||||
.then(result => {if (result.visitorId != '{{v.fp}}') fp(result.visitorId);})
|
||||
</script>
|
||||
{% endif %}
|
||||
|
||||
<div class="row" style="overflow: visible;padding-top:5px;">
|
||||
<div class="col">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
|
|
Loading…
Reference in New Issue