forked from Novators/libsqrl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqrlActionRekey.cpp
More file actions
58 lines (51 loc) · 1.48 KB
/
SqrlActionRekey.cpp
File metadata and controls
58 lines (51 loc) · 1.48 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
/** \file SqrlActionRekey.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 "SqrlActionRekey.h"
#include "SqrlUser.h"
#include "SqrlClient.h"
using libsqrl::SqrlActionRekey;
SqrlActionRekey::SqrlActionRekey() : SqrlIdentityAction( NULL ) {
}
int SqrlActionRekey::run( int cs ) {
SqrlClient *client = SqrlClient::getClient();
if( this->shouldCancel ) {
return this->retActionComplete( SQRL_ACTION_CANCELED );
}
switch( cs ) {
case 0:
if( !this->user ) {
client->callSelectUser( this );
return cs;
}
return cs + 1;
case 1:
if( !this->user->forceRescue( this ) ) {
return this->retActionComplete( SQRL_ACTION_FAIL );
}
return cs + 1;
case 2:
if( !this->user->rekey( this ) ) {
return this->retActionComplete( SQRL_ACTION_FAIL );
}
return cs + 1;
case 3:
if( this->user->getPasswordLength() == 0 ) {
client->callAuthenticationRequired( this, SQRL_CREDENTIAL_NEW_PASSWORD );
return cs;
}
return cs + 1;
case 4:
client->callSaveSuggested( this->user );
return cs + 1;
case 5:
return this->retActionComplete( SQRL_ACTION_SUCCESS );
default:
return this->retActionComplete( SQRL_ACTION_FAIL );
}
}