-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextStep.coffee
More file actions
162 lines (156 loc) · 5.14 KB
/
nextStep.coffee
File metadata and controls
162 lines (156 loc) · 5.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
dyna = @dyna
@b3.promptIdentity = @b3.Prompt::scurry {
dialog: true
confirmation: true
buttonText: ""
type: 'primary'
block: ''
inputType: 'email'
selectClass: 'identity'
header: 'Authentication'
label: 'Please enter your e-mail.'
legend: 'Email identity.'
placeholder: 'e-mail ...'
icon: 'glyphicon glyphicon-envelope'
}
@b3.promptPassword = @b3.Prompt::scurry {
dialog: true
confirmation: true
label: ''
type: 'primary'
buttonText: ""
block: ''
inputType: 'password'
validation: "data-password=6"
selectClass: 'password'
header: 'Authentication'
legend: 'Password.'
label: 'Please enter your password.'
icon: "glyphicon glyphicon-edit"
}
@b3.confirmIdentity = @b3.Prompt::scurry {
dialog: true
confirmation: false
buttonText: ' RESET'
buttonClass: 'warning'
showAltButton: false
altButtonText: " change e-mail."
altSelectClass: "changeUser"
type: 'primary'
selectClass: 'identity'
block: 'alert-block'
inputType: 'text'
header: 'New?'
label: "Please re-enter your e-mail."
legend: 'Confirm email.'
icon: 'glyphicon glyphicon-envelope'
}
dyna.nextStep = (step)=>
repeatStep = Session.equals('dynaStep', step)
if not repeatStep then @b3.Prompt::remove { dialog: true }
Session.set('dynaStep', step)
dyna.resetThrottle()
if Meteor.userId()
dyna.emailMaybe = Meteor.user()?.emails[0]?.address
switch step
when 'resetPassword'
@b3.promptPassword ' a new password', {
header: 'Enter:'
confirmation: true
single: 'resetPassword'
}
return
else
Session.set('dynaStep', 'finished')
return
switch step
when 'init'
@b3.flashInfo ' please sign up or sign in.', {
header: 'Welcome:'
}
when 'identify' #authorization begins;
if not dyna.valid and repeatStep
@b3.promptIdentity 'Invalid email', {
single: 'identify'
value: dyna.identity
header: dyna.userEmail
type: 'warning'
}
else
@b3.promptIdentity "", {
single: 'identify'
}
return
when 'confirmation' #confirm identity then password.
dyna.confirmation = true
if not dyna.valid or repeatStep
@b3.confirmIdentity 'Invalid input.', {
single: 'confirmation'
value: dyna.identity
type: 'warning'
label: dyna.emailMaybe
}
else
@b3.confirmIdentity 'Please confirm new account.', {
single: 'confirmation'
placeholder: 're-enter ... '+dyna.identity
label: 'Please re-type: '+dyna.emailMaybe
}
return
when 'signUpNew', 'signBack' #enter password
if (not dyna.valid) or (repeatStep)
@b3.promptPassword 'Invalid password', {
single: 'password'
type: 'warning'
}
else
@b3.promptPassword "", {
single: 'password'
}
return
when 'forgot' #forgot password
if (not dyna.valid) or (repeatStep)
@b3.confirmIdentity dyna.emailMaybe, {
header: 'Confirm reset: '
confirmation: true
single: 'resetPassword'
value: dyna.identity
buttonClass: 'btn btn-danger'
buttonIcon: 'glyphicon glyphicon-refresh'
type: 'warning'
label: 'Re-enter email for password reset.'
}
else
@b3.confirmIdentity dyna.emailMaybe, {
header: 'Confirm reset: '
confirmation: true
single: 'resetPassword'
buttonClass: 'btn btn-danger'
buttonIcon: 'glyphicon glyphicon-refresh'
type: 'warning'
label: 'Re-enter email for password reset.'
}
when 'resetPassword'
if not dyna.valid or repeatStep
@b3.promptPassword ' a new password', {
header: 'Enter:'
confirmation: true
single: 'resetPassword'
}
else
@b3.promptPassword ' a new password', {
header: 'Enter:'
confirmation: true
single: 'resetPassword'
}
else
return
dyna.reset = =>
dyna.userEmail = 'invalid e-mail'
dyna.userExisting = false
dyna.identity = ''
dyna.emailMaybe = Meteor.user()?.emails[0]?.address or 'No User.'
dyna.confirmation = false
dyna.valid = true
@b3.Prompt::clearAll()
return true