var server = 'http://138.201.116.58:1337/'; // var server = 'http://localhost:1337/';
var app = angular.module('app', []);
app.controller('AppController', function($scope, $http){
$scope.apiURL = server + 'api/v1/golf/change_password'; $scope.prr = getParameterByName('prr'); $scope.formData = { password: '', confirmPassword: '', };
$scope.changePassword = changePassword;
function changePassword() {
if(!$scope.prr) {
alert('No Request Found'); return; }
if(!$scope.formData.password) {
alert('Please enter a password'); return; }
if(!$scope.formData.confirmPassword) {
alert('Please enter confirm password'); return; }
if($scope.formData.password != $scope.formData.confirmPassword) {
alert('Confirm password must match'); return; }
var params = { prr: $scope.prr, password: $scope.formData.password };
$http.post($scope.apiURL, params).then( function successCallback(res) {
alert('Password er nu opdateret. Log in på GolfQuis igen med dit nye password - god fornøjelse.'); }, function errorCallback(err) {
alert('Desværre, der er sket en fejl. Prøv igen.'); } ); }
function getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[[]]/g, "\$&"); var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/+/g, " ")); } });