Skip to content

Commit

Permalink
Profile delete capability. Better iOS support.
Browse files Browse the repository at this point in the history
  • Loading branch information
JudahGabriel committed Dec 27, 2023
1 parent a17b741 commit 8025c70
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 34 deletions.
14 changes: 14 additions & 0 deletions Chavah.NetCore/Controllers/AccountController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,20 @@ public async Task<SupportMessage> SendSupportMessage([FromBody]SupportMessage me
}
}

[HttpPost]
public async Task<IActionResult> DeleteMyAccount()
{
var user = await GetUser();
if (user == null)
{
return Unauthorized();
}

await userManager.DeleteAsync(user);
await signInManager.SignOutAsync();
return Ok();
}

private SignInStatus SignInStatusFromResult(Microsoft.AspNetCore.Identity.SignInResult result, string email)
{
if (result.Succeeded)
Expand Down
4 changes: 1 addition & 3 deletions Chavah.NetCore/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<meta name="mobile-web-app-capable" content="yes" />

@*This allows fixed position elements to work properly*@
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0, viewport-fit=cover">

<meta name="description" content="The very best Messianic Jewish and Hebrew Roots radio on the web" />
<meta name="keywords" content="messianic jewish music hebrew roots radio chavah christian music" />
Expand Down Expand Up @@ -136,7 +136,6 @@
<script src="~/lib/lodash/lodash.js"></script>
<script src="~/lib/rxjs/rx.lite.js"></script>
<script src="~/lib/tslib/tslib.min.js"></script>
<script src="~/lib/fastclick/fastclick.js"></script>
<script src="~/lib/tinycolor/tinycolor.js"></script>

@*Chavah JS*@
Expand Down Expand Up @@ -166,7 +165,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js" crossorigin="anonymous" asp-fallback-src="~/lib/lodash/dist/lodash.js" asp-fallback-test="window._"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/4.1.0/rx.lite.js" crossorigin="anonymous" asp-fallback-src="~/lib/rxjs/dist/rx.all.min.js" asp-fallback-test="window.Rx && window.Rx.Observable"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tslib/1.11.1/tslib.min.js" crossorigin="anonymous" asp-fallback-src="~/lib/tslib/tslib.js" asp-fallback-test="window.__asyncValues"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js" crossorigin="anonymous" asp-fallback-src="~/lib/fastclick/lib/fastclick.js" asp-fallback-test="window.FastClick"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinycolor/1.4.1/tinycolor.min.js" crossorigin="anonymous" asp-fallback-src="~/lib/tinycolor/tinycolor.js" asp-fallback-test="window.tinycolor"></script>

@*Chavah JS*@
Expand Down
8 changes: 0 additions & 8 deletions Chavah.NetCore/libman.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@
"angular-local-storage.js"
]
},
{
"provider": "cdnjs",
"library": "fastclick@1.0.6",
"destination": "wwwroot/lib/fastclick/",
"files": [
"fastclick.js"
]
},
{
"provider": "cdnjs",
"library": "nprogress@0.2.0",
Expand Down
1 change: 0 additions & 1 deletion Chavah.NetCore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@types/angular-route": "^1.3.4",
"@types/angular-ui-bootstrap": "^0.13.45",
"@types/bootstrap": "^3.3.36",
"@types/fastclick": "^1.0.28",
"@types/jquery": "^2.0.48",
"@types/lodash": "^4.14.77",
"@types/modernizr": "^3.5.1",
Expand Down
1 change: 1 addition & 0 deletions Chavah.NetCore/wwwroot/css/app/footer.less
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
text-align: center;
background-color: @brand-background;
z-index: 100;
padding-bottom: env(safe-area-inset-bottom); /* On iPhones and other mobile devices with a notch at the bottom for manipulating windows, give extra padding. Without this, the footer is partially covered by the notch. */

.btn-link {
transition: all .2s linear;
Expand Down
4 changes: 4 additions & 0 deletions Chavah.NetCore/wwwroot/css/app/profile.less
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@
border-radius: 300px;
background-color: @gray-lighter;
}

.delete-account-btn {
text-decoration: none;
}
}
2 changes: 1 addition & 1 deletion Chavah.NetCore/wwwroot/css/app/shared.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ body {
margin-top: 10px;

@media(max-width: @screen-xs-max) {
padding: 0 30px 0 30px;
padding: 0 30px 30px 30px;
}
}
.user-profile-icon {
Expand Down
3 changes: 0 additions & 3 deletions Chavah.NetCore/wwwroot/js/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,4 @@
}
});
}]);

// Setup Fastclick to remove the 300ms click delay on mobile browsers.
document.addEventListener("DOMContentLoaded", () => FastClick.attach(document.body), false);
}
10 changes: 10 additions & 0 deletions Chavah.NetCore/wwwroot/js/Controllers/ProfileController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,16 @@
this.accountApi.currentUser.updateFrom(updatedUser);
}
}

async deleteMyAccount() {
this.isSaving = true;
try {
await this.accountApi.deleteAccount();
window.location.href = "/";
} finally {
this.isSaving = false;
}
}
}

App.controller("ProfileController", ProfileController);
Expand Down
4 changes: 4 additions & 0 deletions Chavah.NetCore/wwwroot/js/Services/AccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@
};
return this.httpApi.post(`${this.apiUri}/resendConfirmationEmail`, args);
}

deleteAccount(): ng.IPromise<any> {
return this.httpApi.post(`${this.apiUri}/deleteMyAccount`, {});
}
}

App.service("accountApi", AccountService);
Expand Down
6 changes: 5 additions & 1 deletion Chavah.NetCore/wwwroot/views/PrivacyPolicy.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ <h3>Privacy Policy</h3>
<p>
Should this policy change in the future, we'll notify you through email.
</p>
</section>
<h3>Account Deletion</h3>
<p>
If you wish to delete your account, go to <a href="#/profile">Profile</a> and then click <strong>Delete My Account</strong>.
</p>
</section>
60 changes: 43 additions & 17 deletions Chavah.NetCore/wwwroot/views/Profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="row">
<div class="col-xs-12 col-sm-8 col-sm-offset-2">
<h2 class="page-title">My profile</h2>

<div class="row">

<!--The profile pic column-->
Expand All @@ -11,9 +11,8 @@ <h2 class="page-title">My profile</h2>
<!--Show the profile pic if we've got one-->
<div ng-if="vm.profilePicUrl" class="text-center">
<div class="img-container">
<img class="img-responsive profile-pic" ng-src="{{vm.profilePicUrl}}" />
<img class="img-responsive profile-pic" ng-src="{{vm.profilePicUrl}}" ng-click="vm.launchImagePicker()" />
</div>
<!--<div class="profile-pic" background-image="vm.profilePicUrl" ng-click="vm.launchImagePicker()"></div>-->
<br />
<label class="btn btn-default btn-file btn-sm">
Change my profile photo
Expand All @@ -26,7 +25,7 @@ <h2 class="page-title">My profile</h2>

<!--The placeholder tile-->
<div class="panel panel-default profile-pic-placeholder">
<div class="panel-body needsclick" ng-click="vm.launchImagePicker()" aria-hidden="true">
<div class="panel-body" ng-click="vm.launchImagePicker()" aria-hidden="true" role="button">
<h4>
<i class="fa fa-user-circle-o fa-5x"></i>
<br />
Expand All @@ -35,7 +34,7 @@ <h4>
Add a profile photo
</h4>
</div>
<input type="file" class="form-control-file needsclick sr-only" accept="image/*" id="imagePicker" file-upload-changed="vm.profilePicChanged(e)" />
<input type="file" class="form-control-file sr-only" accept="image/*" id="imagePicker" file-upload-changed="vm.profilePicChanged(e)" />
</div>

<!--The loading indicator-->
Expand Down Expand Up @@ -95,22 +94,49 @@ <h4>
</div>
</form>

<button class="btn btn-primary" ng-disabled="vm.isSavingOrUploading" ng-click="vm.save()">
<span ng-hide="vm.isSavingOrUploading">
<i class="fa fa-save"></i> Save
</span>
<span ng-show="vm.isSavingOrUploading">
<i class="fa fa-circle-o-notch fa-spin"></i> Saving...
</span>
</button>
<div style="display: flex; justify-content: space-between;">
<button class="btn btn-primary" ng-disabled="vm.isSavingOrUploading" ng-click="vm.save()">
<span ng-hide="vm.isSavingOrUploading">
<i class="fa fa-save"></i> Save
</span>
<span ng-show="vm.isSavingOrUploading">
<i class="fa fa-circle-o-notch fa-spin"></i> Saving...
</span>
</button>

<p class="text-success" ng-show="vm.hasSavedSuccessfully">
<br />
<i class="fa fa-check"></i> Profile saved
</p>
<button class="btn btn-link delete-account-btn" data-toggle="modal" data-target="#confirmDeleteAccount" ng-disabled="vm.isSavingOrUploading">
<i class="fa fa-trash-o text-danger"></i>
<span class="text-danger">Delete my account</span>
</button>
</div>
</div>

</div>
</div>
</div>

<div id="confirmDeleteAccount" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close" ng-disabled="vm.isSavingOrUploading"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">Are you sure?</h4>
</div>
<div class="modal-body">
<p>Do you really want to delete <strong>{{vm.user.email}}</strong>?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" ng-disabled="vm.isSavingOrUploading">Cancel</button>
<button type="button" class="btn btn-danger" ng-click="vm.deleteMyAccount()" ng-disabled="vm.isSavingOrUploading">
<span ng-hide="vm.isSavingOrUploading">
<i class="fa fa-trash-o"></i> Delete my account
</span>
<span ng-show="vm.isSavingOrUploading">
<i class="fa fa-circle-o-notch fa-spin"></i> Deleting...
</span>
</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</section>

0 comments on commit 8025c70

Please sign in to comment.