forked from Novators/libsqrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqrlActionChangePassword.cpp
More file actions
54 lines (48 loc) · 1.69 KB
/
Copy pathSqrlActionChangePassword.cpp
File metadata and controls
54 lines (48 loc) · 1.69 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
/** \file SqrlActionChangePassword.cpp
*
* \author Adam Comley
*
* This file is part of libsqrl. It is released under the MIT license.
* For more details, see the LICENSE file included with this package.
**/
#include "sqrl_internal.h"
#include "SqrlActionChangePassword.h"
#include "SqrlClient.h"
#include "SqrlUser.h"
namespace libsqrl
{
SqrlActionChangePassword::SqrlActionChangePassword() : SqrlIdentityAction( NULL ) {}
SqrlActionChangePassword::SqrlActionChangePassword( SqrlUser *user ) : SqrlIdentityAction( user ) {}
int SqrlActionChangePassword::run( int cs ) {
SqrlClient *client = SqrlClient::getClient();
if( this->shouldCancel ) {
COMPLETE( SQRL_ACTION_CANCELED );
}
switch( cs ) {
case 0:
// Ensure that a User is selected; call client::callSelectUser() if not.
if( !this->user ) {
client->callSelectUser( this );
SAME_STATE( cs )
}
NEXT_STATE( cs )
case 1:
// Decrypt the user identity, requesting authentication if needed.
// TODO: forceDecrypt should be a SqrlAction ?
if( !this->user->forceDecrypt( this ) ) {
COMPLETE( SQRL_ACTION_FAIL )
}
NEXT_STATE( cs )
case 2:
// Request a new Password
client->callAuthenticationRequired( this, SQRL_CREDENTIAL_NEW_PASSWORD );
NEXT_STATE( cs )
case 3:
// Suggest saving the modified identity.
client->callSaveSuggested( this->user );
COMPLETE( SQRL_ACTION_SUCCESS );
default:
COMPLETE( SQRL_ACTION_FAIL );
}
}
}