rewrite2 add registration (thanks mobile app!)

This commit is contained in:
Tyler Renelle 2013-08-25 22:53:51 -04:00
parent 63ff9c4174
commit 9b25dc67ff
3 changed files with 18 additions and 27 deletions

View file

@ -15,14 +15,16 @@ habitrpg.controller "AuthCtrl", ($scope, $rootScope, Facebook, LocalAuth, User,
localStorage.clear()
location.reload()
runAuth = (id, token) ->
User.authenticate id, token, (err) ->
$rootScope.modals.login = false
$scope.register = ->
#TODO highlight invalid inputs
# we have this as a workaround for https://github.com/HabitRPG/habitrpg-mobile/issues/64
return if $scope.registrationForm.$invalid
$http.post(API_URL + "/api/v1/register", $scope.registerVals).success((data, status, headers, config) ->
User.authenticate data.id, data.apiToken, (err) ->
$location.path "/habit"
runAuth data.id, data.apiToken
).error (data, status, headers, config) ->
if status is 0
alert "Server not currently reachable, try again later"
@ -31,24 +33,17 @@ habitrpg.controller "AuthCtrl", ($scope, $rootScope, Facebook, LocalAuth, User,
else
alert "ERROR: " + status
$scope.auth = ->
data =
username: $scope.loginUsername
password: $scope.loginPassword
runAuth = (id, token) ->
User.authenticate id, token, (err) ->
$rootScope.modals.login = false
if $scope.useUUID
runAuth $scope.loginUsername, $scope.loginPassword
else
$http.post(API_URL + "/api/v1/user/auth/local", data)
.success((data, status, headers, config) ->
runAuth data.id, data.token
$rootScope.modals.login = false
).error (data, status, headers, config) ->
if status is 0
alert "Server not currently reachable, try again later"

View file

@ -26,19 +26,4 @@ block content
footer.footer
.container
h4 Todo
ul
li
strong Notifications
li
strong Sort
li Due Dates
li Reroll
li Graphs
li Footer
li Clear Completed (need API route)
li Static Pages
li Optimize (see <a href="https://github.com/HabitRPG/habitrpg-mobile/issues/90#issuecomment-23241019">performance conversation</a>)
h4 Options
ul
li TODO - add roadmap for options pane
a(target='_blank',href='https://workflowy.com/shared/9c77c53d-a174-d181-73a4-dc611508a936/') Roadmap

View file

@ -21,7 +21,18 @@ div(ng-controller='AuthCtrl')
input.btn.btn-primary(type='submit', value='Login')
tab(heading='Register')
| derby-auth:register
form(ng-submit='register()', name='registrationForm')
.control-group
input(type='text', ng-model='registerVals.username', placeholder='Username', required)
.control-group
input(type='email', ng-model='registerVals.email', placeholder='Email', required)
.control-group
input(type='password', ng-model='registerVals.password', placeholder='Password', required)
.control-group
input(type='password', ng-model='registerVals.confirmPassword', placeholder='Password Confirm', required)
.control-group
input.btn.btn-primary(type='submit', value='Register')
.modal-footer
button.btn.btn-warning.cancel(ng-click='modals.login = false') Cancel