Skip to content

Commit

Permalink
Merge pull request #554 from NBISweden/feature/sftp-fixing
Browse files Browse the repository at this point in the history
Fix sFTP for Postgres
  • Loading branch information
norling committed May 7, 2019
2 parents e94a615 + a556670 commit 07cea86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
6 changes: 4 additions & 2 deletions backend/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,18 +632,20 @@ def post(self):
expires = datetime.today() + timedelta(days=30)

# Check if an sFTP user exists for the current user when the database is ready
passwd_hash = fn.encode(fn.digest(password, 'sha256'), 'hex')

try:
self.current_user.sftp_user.get()
# if we have a user, update it
db.SFTPUser.update(password_hash = fn.SHA2(password, 256),
db.SFTPUser.update(password_hash = passwd_hash,
account_expires = expires
).where(db.SFTPUser.user == self.current_user).execute()
except db.SFTPUser.DoesNotExist:
# if there is no user, insert the user in the database
db.SFTPUser.insert(user = self.current_user,
user_uid = db.get_next_free_uid(),
user_name = username,
password_hash = fn.SHA2(password, 256),
password_hash = passwd_hash,
account_expires = expires
).execute()

Expand Down
35 changes: 0 additions & 35 deletions frontend/templates/ng-templates/dataset-admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<ul class="nav nav-tabs pull-right">
<li class="active"><a data-target="#pending" data-toggle="tab">Pending requests</a></li>
<li><a data-target="#approved" data-toggle="tab">Approved users</a></li>
<li><a data-target="#sftp" data-toggle="tab">sFTP Access</a></li>
<li><a data-target="#emaillist" data-toggle="tab">Email list</a></li>
</ul>
</div>
Expand Down Expand Up @@ -73,40 +72,6 @@
</div>
</div>

<div class="tab-pane" id="sftp">
<div class="col-sm-6 center-block" style="float:none">
<h3>sFTP Credentials</h3>
<div class="form-horizontal">
<div class="form-group">
<label for="sftp-user" class="col-sm-4 control-label">Username</label>
<div class="col-sm-8">
<input id="sftp-user" type="text" class="form-control" value="{{ ctrl.sftp.user }}" readonly>
</div>
</div>

<div class="form-group">
<label for="sftp-pass" class="col-sm-4 control-label">Password</label>
<div class="col-sm-8">
<input id="sftp-pass" type="text" class="form-control" value="{{ ctrl.sftp.password }}" readonly>
</div>
</div>

<div class="form-group">
<label for="sftp-expiry" class="col-sm-4 control-label">Expiry date</label>
<div class="col-sm-8">
<input id="sftp-expiry" type="text" class="form-control" value="{{ ctrl.sftp.expires }}" readonly>
</div>
</div>

<div class="form-group">
<div class="col-sm-8 col-sm-offset-4">
<button type="button" ng-click="ctrl.createSFTPCredentials()" class="btn btn-primary form-control">Generate Credentials</button>
</div>
</div>
</div>
</div>
</div>

<div class="tab-pane" id="emaillist">
<span ng-repeat="user in ctrl.users.current">
<span ng-if="user.newsletter">
Expand Down

0 comments on commit 07cea86

Please sign in to comment.